To make an SSH conection over Tor you'll need a small program called 'connect.c'
It is available in many Linux distros in the pakage named 'connect-proxy' or 'connect'
Or you can build it from source: https://bitbucket.org/gotoh/connect/
Microsoft Windows version is also avilable.
apt-get install connect-proxy
To run SSH over Tor, run the following command. Substitute your username for andries and the IP address you wish to connect for 18.104.22.168 .
ssh -l email@example.com -o ProxyCommand="/usr/bin/connect -4 -S localhost:9050 %h %p"
"-o" passes the following argument as option in the format used in the configuration file. In this case, it passes the option ProxyCommand with the value of "/usr/bin/connect -4 -S localhost:9050 %h %p". Port 9050 is the default portnumber for tor. /usr/bin/connect is a full path to 'connect' executable.
The "-4" option tells connect to use SOCKS protocol 4.
The "-S" option specifies the hostname and port number of the SOCKS server to relay.
Do not pass a hostname instead of an IP address as the remote machine to which you wish to connect, use tor-resolve if you don't know the IP.
tor-resolve google.com localhost:9050