Tor Hidden Service in Ubuntu/Debian

tor browser

To install tor on Ubuntu/Debian, run

apt install tor

Default configuration file for tor is /etc/tor/torrc

To enable hidden service, edit /etc/tor/torrc

vi /etc/tor/torrc

uncomment lines

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80

Create folder for your hidden service

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

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

cat /var/lib/tor/hidden_service/hostname

Example

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

systemctl enable tor@default

See Tor

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *