40

I have a working installation of Tor. I am able to both access hidden services and proxy my clear-net traffic through Tor. My main source of traffic so far has been HTTP.

I would like to know how I can use Tor to access remote computers through the use of SSH. I would like answers for the major operating systems: Windows, Linux/Unix, Mac OS X.

Further, can programs such as rsync be made to use the Tor network?

2
  • 4
    Usually questions should cover just one topic. So it might be a good idea to ask your rsync question separately. Commented Sep 26, 2013 at 18:32
  • @JensKubieziel Normally I'd agree with you, but rsync and SSH are so closely tied in this example (since rsync is using ssh as its remote shell) that I personally would think this one is okay.
    – user5
    Commented Sep 27, 2013 at 15:57

5 Answers 5

26

For SSH you can do something like the following:

ssh -o ProxyCommand='nc -x localhost:$orport %h %p' example.com

Options can also be configured in your ~/.ssh/config (or /etc/ssh/ssh_config, or the equivalent on your OS) file:

Host example
    Hostname example.com
    ProxyCommand /usr/bin/nc -x localhost:$orport %h %p

Rsync can then use ssh as its remote shell and it will pick up the previous config:

rsync -e ssh example:path/to/files /dest

or, by directly passing arguments to the remote shell:

rsync -e "ssh -o ProxyCommand='nc -x localhost:$orport %h %p'" example.com /dest

Finally, you can use the RSYNC_CONNECT_PROG environment variable to set up all future RSYNC invocations to use Tor (without having to manually specify it each time):

export RSYNC_CONNECT_PROG='ssh proxyhost nc -x localhost:$orport %h %p'
rsync example.com:/src /dest 

Replace $orport with the port you've got Tor's SOCKS proxy listening on.

2
  • Right. Note this also works for hidden services. For example: ssh -o ProxyCommand='nc -x localhost:9050 %h %p' wjawsduj7uxqnqhu.onion Commented Sep 27, 2013 at 5:46
  • 2
    I just did the netcat proxy command here on Gentoo. There is a detail here: Gentoo's default netcat is netcat6, which has a different command line invocation. To use this method, you first have to install OpenBSD netcat with emerge openbsd-netcat. This will install nc.openbsd. Then, do the SSH ProxyCommand method discussed above, substituting nc.openbsd instead of just nc.
    – RAKK
    Commented Jul 15, 2015 at 15:37
13

If you are using PuTTY you can configure it to use the Tor client as a SOCKS proxy directly. In Configuration > Connection > Proxy select SOCKS 5, enter localhost and the port Tor client is listening on. The Tor Browser Bundle listens on port 9150 by default. Keep in mind that functional SOCK proxy is available only after starting the Tor client (or Tor Browser) and connecting it to the Tor network.

The picture shows how the setting looks like in PuTTY 0.67.

SOCK proxy setting in PuTTY

Note that one of the really cool things about PuTTY is that it's cross-platform, so this technique should work on both Linux and Windows. Use sudo apt install putty to install PuTTY in Ubuntu, for instance.

1
  • this works great, just we need to start the tor browser and connected to tor network.
    – Mani
    Commented Jun 30, 2023 at 18:47
8

Using one of the anonymity (Tor) focused operating systems, such as Tails, QubesOS TorVM, Liberte Linux or Whonix is another option.

(Full disclosure: I am a maintainer of Whonix.)

6

Read this article if you are interested: Pietro Abate homepage: hidden ssh service via tor / 16 October 2010

You can use proxifier called torsocks:

# torsocks ssh user@host

Torsocks allows you to use most SOCKS-friendly applications in a safe way with Tor. It ensures that DNS requests are handled safely and explicitly rejects UDP traffic from the application you're using.

6

My config for all connections looks like:

nano /etc/ssh/sshd_config

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

And for some domains it can looks like:

Host mydomain
HostName mydomain.com
User myaccount
CheckHostIP no
Compression yes
Protocol 2
ProxyCommand connect -4 -S localhost:9050 $(tor-resolve %h localhost:9050) %p

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .