The Tor Project maintains its own RPM package repository for CentOS and RHEL and Fedora.
Note: The symbol # refers to be running the code as root. That means you should have access to a user account with system administration privileges, e.g your user should be in the sudo group.
Here's how you can enable Tor Package Repository for both CentOS and RHEL and Fedora:
1. Enable epel repository (only for CentOS and RHEL)
# dnf install epel-release -y
2. Add the following to /etc/yum.repos.d/tor.repo
For CentOS or RHEL:
[tor]
name=Tor for Enterprise Linux $releasever - $basearch
baseurl=https://rpm.torproject.org/centos/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=https://rpm.torproject.org/centos/public_gpg.key
cost=100
For Fedora:
[tor]
name=Tor for Fedora $releasever - $basearch
baseurl=https://rpm.torproject.org/fedora/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=https://rpm.torproject.org/fedora/public_gpg.key
cost=100
3. Install the Tor package
Then you can install the latest Tor package.
# dnf install tor -y
Using it for the first time, you will have to import the GPG public key.
Importing GPG key 0x3621CD35:
Userid : "Kushal Das (RPM Signing key) <kushal@torproject.org>"
Fingerprint: 999E C8E3 14BC 8D46 022D 6C7D E217 C30C 3621 CD35
From : https://rpm.torproject.org/fedora/public_gpg.key
Is this ok [y/N]: y