Skip to content

Instantly share code, notes, and snippets.

@ethicnology
Last active May 16, 2023 12:30
Show Gist options
  • Save ethicnology/717b001d4e765657917b0d2423799558 to your computer and use it in GitHub Desktop.
Save ethicnology/717b001d4e765657917b0d2423799558 to your computer and use it in GitHub Desktop.
SSH over TOR

SSH over TOR

server

install tor

sudo apt install tor

edit /etc/tor/torrc

HiddenServiceDir /var/lib/tor/sshd/
HiddenServicePort 22 127.0.0.1:22

restart

sudo service tor restart

This will create some configuration files in the HiddenServiceDir.

sudo ls /var/lib/tor/sshd/
# authorized_clients  hostname  hs_ed25519_public_key  hs_ed25519_secret_key

The hostname file contain the address.onion of your hidden service

client

sudo apt install tor netcat-openbsd

edit ~/.ssh/config

# Generic configuration for all .onion hosts that proxies onion traffic through the local tor service
Host *.onion
        ProxyCommand /bin/nc -xlocalhost:9050 -X5 %h %p

Host <yourServiceName.onion>
        User <yourUser>
        Hostname <yourAddress.onion>
        IdentityFile <~/.ssh/yourKey>
        Port 22
        
Host example.onion
        User ubuntu
        Hostname 64cf46271c1e23ab976fb848b923fbbc5080d3ac922735e0c3c95b9e088e8763.onion
        IdentityFile ~/.ssh/ed25519
        Port 22

CREDIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment