Accessing a server with no public IP


There is a computer that does not have a public IP that I want to make accessible for remote ssh login. This is machine A. I am logging in from a random machine B that could be anywhere in the world. Machine C is a public server that I have access to.

Setup the public machine

I create a user on machine C called fwd Then I add the following line to /etc/ssh/ssh_config on machine C:

GatewayPorts yes

On the machine without a public IP

Don't forget to start the ssh server on machine A (may already be running):

user@machineA:~$ sudo systemctl enable sshd
user@machineA:~$ sudo systemctl start sshd

Then I can run this command on machine A to connect it's local ssh port to machine C's port 8000:

user@machineA:~$ ssh -R \*:8000:localhost:22 fwd@machineC

Logging in remotely

To log in, execute on machine B to log into machine C:

user@machineB:~$ ssh fwd@machineC

Then execute on machine C to log in to machine A:

fwd@machineC:~$ ssh user@localhost -p 8000

Congratulations! You are now logged in to machine A from machine B anywhere in the world.

user@machineA:~$ nyancat

Credit to [](this serverfault post) for the original process.