install tor
sudo apt install toredit /etc/tor/torrc
HiddenServiceDir /var/lib/tor/sshd/
HiddenServicePort 22 127.0.0.1:22restart
sudo service tor restartThis will create some configuration files in the HiddenServiceDir.
sudo ls /var/lib/tor/sshd/
# authorized_clients hostname hs_ed25519_public_key hs_ed25519_secret_keyThe hostname file contain the address.onion of your hidden service
sudo apt install tor netcat-openbsdedit ~/.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