SSH Access with HiddenService

SSH Access with HiddenService

SSH access with HiddenService.

To have access to a machine by ssh without the need to give ip static or fight with firewalls.

On the machine where we need to access, we will install the tor service, add the directory and port 22 of ssh in the config, and launch the tor service.

apt install tor

vim /etc/tor/torrc
    HiddenServiceDir /var/lib/tor/ssh_service
    HiddenServicePort 22 
systemctl restart tor

The hidden service hostname we will need is found by doing so:

cat /var/lib/tor/ssh_service/hostname

Next, we must give him the ssh key that we authorized to enter to this machine, for it we will create the directory ssh, we will give him only permissions to root.

mkdir /root/.ssh

chmod 700 /root/.ssh

And we will have to put the public key of ssh to which we want to give access to the machine..

vim authorized_keys 

Now we will be able to access from outside with:

ssh root@[hostname.onion]