# How to install Tor

Linux
macOS
BSD
Source
Debian / Ubuntu

Do not use the packages in Ubuntu's universe. In the past they have not reliably been updated. That means you could be missing stability and security fixes.

The Tor Project maintains its own Debian package repository. Since Debian provides the LTS version of Tor, this might not always give you the latest stable Tor version. Therefore, it's recommended to install `tor` from our repository.

Here's how you can enable Tor Package Repository in Debian based distributions:

#### Prerequisite: Verify the CPU architecture

The package repository offers `amd64` and `arm64` binaries. Verify your operating system is capable of running the binary by inspecting the output of the following command:

    $ sudo dpkg --print-architecture

It should output either `amd64` or `arm64`. The repository does not support other CPU architectures.

#### 1. Install `apt-transport-https`

To enable all package managers using the libapt-pkg library to access metadata and packages available in sources accessible over https (Hypertext Transfer Protocol Secure).

    $ sudo apt install apt-transport-https

#### 2. Create a new file in `/etc/apt/sources.list.d/` named `tor.sources` and add the following entry:

    Types: deb deb-src
    URIs: https://deb.torproject.org/torproject.org/
    Suites: <DISTRIBUTION>
    Components: main
    Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

If you want to try experimental packages, add this stanza in addition to the lines above:

    Types: deb deb-src
    URIs: https://deb.torproject.org/torproject.org/
    Suites: tor-experimental-<DISTRIBUTION>
    Components: main
    Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

For nightly builds, add the following:

    Types: deb deb-src
    URIs: https://deb.torproject.org/torproject.org/
    Suites: tor-nightly-main-<DISTRIBUTION>
    Components: main
    Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

Replace `<DISTRIBUTION>` with your operating system's codename. You can run `lsb_release -c` or check `/etc/os-release` to find it.

If you add multiple entries to your file, make sure to add at least one empty line between each entry.

Note: The `tor.sources` file shown above uses the deb822 format, which is supported by APT 1.1 and later. If you're using an older version of APT (typically found on older Debian or Ubuntu releases), this format may not be supported. In that case, you can instead add the following to a `tor.list` file in `/etc/apt/sources.list.d/` to achieve the same result.

    deb     [signed-by=/usr/share/keyrings/deb.torproject.org-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main
    deb-src [signed-by=/usr/share/keyrings/deb.torproject.org-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main

#### 3. Install GnuPG if not already installed:

    $ sudo apt install gnupg

#### 4. Then add the gpg key used to sign the packages by running the following command at your command prompt:

    $ wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | sudo tee /usr/share/keyrings/deb.torproject.org-keyring.gpg >/dev/null

#### 5. Install tor and tor debian keyring

We provide a Debian package to help you keep our signing key current. It is recommended you use it. Install it with the following commands:

    $ sudo apt update
    $ sudo apt install tor deb.torproject.org-keyring

Fedora

The Tor Project maintains its own RPM package repository for CentOS and RHEL and Fedora.

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)

    $ sudo 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.

    $ sudo 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

Void linux

To install the `tor` package on Void Linux, please run:

`# xbps-install -S tor`

Arch Linux

To install the `tor` package on Arch Linux, run:

`# pacman -Syu tor`

#### Install a package manager

There are two package managers on OS X: Homebrew and Macports. You can use the package manager of your choice.

To install Homebrew follow the instructions on brew.sh.

To install Macports follow the instructions on macports.org.

#### Package installation

If you are using Homebrew in a Terminal window, run:

`# brew install tor`

If you are using Macports in a Terminal window, run:

`$ sudo port install tor`

FreeBSD

To install the `tor` package on FreeBSD, run:

`# pkg install tor`

OpenBSD

To install the `tor` package on OpenBSD, run:

`# pkg_add tor`

NetBSD

#### Setup `pkg_add`

Modern versions of the NetBSD operating system can be set to use `pkgin`, which is a piece of software aimed to be like `apt` or `yum` for managing pkgsrc binary packages. We are not convering its setup here, and opt to use plain `pkg_add` instead.

`# echo "PKG_PATH=http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/$(uname -m)/$(uname -r)/All" > /etc/pkg_install.conf`

#### Package installation

Install `tor` NetBSD's package:

`# pkg_add tor`

DragonFlyBSD

#### Bootstrap `pkg`

DragonFlyBSD's daily snapshots and releases (starting with 3.4) come with `pkg` already installed. Upgrades from earlier releases, however, will not have it. If `pkg` is missing on the system for any reason, it can be quickly bootstrapped without having to build it from source or even having DPorts installed:

    # cd /usr
    # make pkg-bootstrap
    # rehash
    # pkg-static install -y pkg
    # rehash

#### Recommended steps to setup `pkg`

Here, it will be similar to what we have on a FreeBSD system, and we are going to use HTTPS to fetch our packages, and updates - so here we also need an extra package to help us out (`ca_root_nss`).

#### Installing the `ca_root_nss` package:

`# pkg install ca_root_nss`

For fresh installations, the file `/usr/local/etc/pkg/repos/df-latest.conf.sample` is copied to `/usr/local/etc/pkg/repos/df-latest`. The files ending in the ".sample" extension are ignored; pkg(8) only reads files that end in ".conf" and it will read as many as it finds.

DragonflyBSD has 2 packages repositories:

- Avalon (mirror-master.dragonflybsd.org);
- Wolfpond (pkg.wolfpond.org).

We can simply edit the URL used to point out the repositories on `/usr/local/etc/pkg/repos/df-latest` and that's it! Remember to use pkg+https:// for Avalon.

After applying all these changes, we update the packages list again and try to check if there's already a new update to apply:

    # pkg update -f
    # pkg upgrade -y -f

#### Package installation

Install the `tor` package:

`# pkg install tor`

##### Download latest release and dependencies

The latest release of Tor can be found on the download page.

If you're building from source, first install libevent, and make sure you have openssl and zlib (including the -devel packages if applicable).

##### Install `tor`

`tar -xzf tor-<version>.tar.gz; cd tor-<version>`

Replace `<version>` with the latest version of `tor`, for example, `tor-0.4.8.12`

`./configure && make`

Now you can run tor as `src/app/tor` (0.4.3.x and later), or you can run `make install` (as root if necessary) to install it into `/usr/local/`, and then you can start it just by running tor.