How to use SSH with Tor?

Solution 1:

With Tor running, you can use torify command. Eg:

torify ssh user@remotehost
torify curl curlmyip.com

Solution 2:

From http://www.howtoforge.com/anonymous-ssh-sessions-with-tor:

Add the following block to the top of your ~/.ssh/config file.

Host *
CheckHostIP no
Compression yes
Protocol 2
ProxyCommand connect -4 -S localhost:9050 $(tor-resolve %h localhost:9050) %p

Solution 3:

Use proxychains for it. It comes preconfigured to use a local tor proxy. Also you might want to avoid using DNS names on such activities as those might resolve the IP outside of tor, which is unwanted. (Thugh I hadn't checked if this is the case or not when using proxychains out of the box.)

Solution 4:

If torify fails on your platform then try this :

Install connect in your path, maybe by building connect.c from source.

Create a script called ssh-tbb :

#!/bin/bash
export CONNECT_PASSWORD=""
exec ssh -o ProxyCommand="connect -5 -S 127.0.0.1:9150 %h %p" $*

You could make other programs like git work by creating scripts like this git-tbb one :

#!/bin/bash
export GIT_SSH=`which ssh-tbb` git pull
exec git $*

Rename them to -tor if you change the port to 9050 for the default tor config, as opposed to TBB's default 9150.

Solution 5:

Just install tor using

sudo apt-get install tor -y

and then user ssh as

tor ssh user@ip_of_server -p port

Simple as that