SSH to Your Tor Onion SSHD
You might need to connect to your server via a Tor Hidden Service and bypass certain censorship attempts on networks you’re using.
First modify your
/etc/sshd_config adding an alternate port you want to use.
Port 3312 can just as well be
Port 5542 or any other number you want.
# systemd systemctl restart sshd # osx launchctl launchctl stop com.openssh.sshd
DataDirectory /var/lib/tor HiddenServiceDir /var/lib/tor/hidden_services/my-hidden-service HiddenServicePort 3312 127.0.0.1:3312
/var/lib/tor for whatever it is on your system. Like
Get your onion address.
For our example we’ll call it
my-hidden-service.onion which is invalid. Yours will be some random funky string.
# systemd systemctl restart tor # osx homebrew service brew service restart tor
Host my-hidden-service HostName my-hidden-service.onion ProxyCommand /usr/bin/nc -X 5 -x '127.0.0.1:9050' %h %p Port 3312 User debian IdentityFile ~/.ssh/my-hidden-service.pem
IdentityFile for whatever it is on your system.
ProxyCommand /usr/bin/nc -X 5 -x '127.0.0.1:9050' %h %p is going to route your connection over the local Tor socks proxy.
Hopefully that will work for your purposes as it has mine.
Take care and good onion-ing.