Access to your private home server is always a long-suffering story, some solutions are the following:
- use a Dynamic DNS and publish your services on the entire network – it’s a very fast solution but has some problems with privacy and with rolling IP
- REMOT3.IT/DATAPLICITY and similar services that publish shell on the web – not very fast and use a connection to a central web service
- TOR network – fast enough for SSH and simple web interfaces use the secure TOR network
TOR look very promising and secure, let’s try it.
TOR
What is Tor?
Tor is free software and an open network that helps you defend against traffic analysis, a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security.
Based on a tunnel in TOR network you can also connect to other nodes that export various services.
Install Tor
Tor is available in the Debian/Armbian repositories so you can install easily with the command:
1 |
apt-get install tor |
The TOR daemon will automatically start on boot in the same manner other services are managed.
Configure Tor
Modify the file /etc/tor/torrc in order to export services
1 2 3 |
HiddenServiceDir /var/lib/tor/hidden-service/ HiddenServicePort 80 127.0.0.1:80 HiddenServicePort 22 127.0.0.1:22 |
In this example, I exported SSH server (port 22) and web server (port80).
1 |
/etc/init.d/tor restart |
Then you can get the unique name of your board with the following command.
1 |
cat /var/lib/tor/hidden-service/hostname |
Connect to your Raspberry Pi
It’s time to connect, with the previous command you received a unique name of the format xxxxxxxxxxxxxxxx.onion, this is the name of your board in the TOR network.
If you want to connect start TOR on your computer and connect using the command:
1 |
ssh pi@xxxxxxxxxxxxxxxx.onion -o ProxyCommand='nc -x 0:9050 %h %p' |
Now you can use the board from everywhere in the world!