Tor install script.
Table of Contents
This script is based on Tor Project's updated documentation. The script should work for any version of Debian or Ubuntu. Please message me if you have a recommendation for improving it.
Easy mode
curl -s https://yawnbox.is/scripts/tor_install.sh | sudo bash
The script
#!/bin/bash
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo -e "${GREEN}Checking CPU architecture...${NC}"
ARCH=$(dpkg --print-architecture)
if [[ "$ARCH" != "amd64" && "$ARCH" != "arm64" && "$ARCH" != "i386" ]]; then
echo -e "${GREEN}Unsupported architecture: $ARCH${NC}"
exit 1
fi
echo -e "${GREEN}Installing apt-transport-https...${NC}"
apt install apt-transport-https -y
echo -e "${GREEN}Checking for GPG installation...${NC}"
if ! command -v gpg > /dev/null; then
echo -e "${GREEN}GPG not found, installing...${NC}"
apt update && apt install gpg -y
else
echo -e "${GREEN}GPG is already installed.${NC}"
fi
echo -e "${GREEN}Checking for Tor installation...${NC}"
if ! command -v tor > /dev/null; then
echo -e "${GREEN}Tor not found, installing...${NC}"
echo "Adding Tor Project repository..."
echo "deb [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/tor.list
wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | tee /usr/share/keyrings/tor-archive-keyring.gpg >/dev/null
apt update
apt install tor deb.torproject.org-keyring -y --no-install-recommends
else
echo -e "${GREEN}Tor is already installed. Version: $(tor --version)${NC}"
fi
echo -e "${GREEN}Checking Tor version...${NC}"
tor --version
yawnbox