Tor Hidden Service in Ubuntu/Debian
To install tor on Ubuntu/Debian, run
1 |
apt install tor |
Default configuration file for tor is /etc/tor/torrc
To enable hidden service, edit /etc/tor/torrc
1 |
vi /etc/tor/torrc |
uncomment lines
1 2 |
HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:80 |
Create folder for your hidden service
1 2 3 |
mkdir /var/lib/tor/hidden_service/ chmod 700 /var/lib/tor/hidden_service/ chown -R debian-tor:debian-tor /var/lib/tor/hidden_service/ |
You need to install Apache/Nginx etc.. to serve your web application. Make sure to configure web application listen on 127.0.0.0:80
Now restart tor with command
1 |
systemctl start tor@default |
Ubuntu/Debian support multiple instances of tor. You can use command “/usr/sbin/tor-instance-create” to create new tor instance. Configuration for instanced tor available at /etc/tor/instances/INSTANCE_NAME/torrc
To see URL for your Hidden service, run
1 |
cat /var/lib/tor/hidden_service/hostname |
Example
1 2 3 |
root@lab:~# cat /var/lib/tor/hidden_service/hostname 3w2pkr2qcusd6rx7zq4rulq7kt4xjpsgv7nxubcy2bdbgipy4wto4aid.onion root@lab:~# |
You should be able to visit the application using .onion link in Tor Browser.
You need to take backup of tor folder (/var/lib/tor/hidden_service) as it contains your secret keys, this is needed to use the .onion domain name. If you lose this, you will lose the .onion url.
To start the service on boot, run
1 |
systemctl enable tor@default |
See Tor