Skip to content

Setting up SSH through TOR hidden services

Christopher Hopkins edited this page Nov 17, 2024 · 8 revisions

You want to be able to SSH to a server that you either can't or don't want to make publicly accessible over the Internet.

Both the machine you are SSHing into and the machine you are connecting from need to have TOR installed and running.

On the machine you are SSHing into

In the /etc/tor/torrc file, un-comment the The Other Hidden Services lines so they look like this:

HiddenServiceDir /var/lib/tor/other_hidden_service/ #HiddenServicePort 80 127.0.0.1:80 HiddenServicePort 22 127.0.0.1:22

Restart the TOR service (to ensure the configuration change is in effect

Obtain the Onion service name of the SSH service in the /var/lib/tor/other_hidden_service/hostname file (You will need to know this to connect to the service)

On the machine you are connecting from

In order to make connecting easy, create a config file in your user's .ssh directory with the following lines:

host hidden hostname hiddenservicename.onion proxyCommand ncat --proxy 127.0.0.1:9050 --proxy-type socks5 %h %p

Replace the hiddenservicename.onion with the hidden service name you obtained from the SSH server

To connect to the SSH server via TOR:

ssh serverusername@hidden

Note: The connection will be slower than a non-TOR connection. Think of it as the price you pay for privacy.

Clone this wiki locally