I has a machine named A(doesn't have private IP) in my LAN, and I want to connect the machine A via SSH, but my host is not in the LAN. I have a machine B(it has private IP), I want to set the machine B as the proxy machine so that I can connect the machine A from my localhost via the machine B(proxy machine) anywhere.

How can I make it by using SSH?


I found autossh is very helpful,

In machine A, type the following commands to create reverse connection

$ autossh -f -N -R port_num:localhost:22 username@proxy_machine

Now, you can connect machine A anywhere

$ ssh -t username@proxy_machine "ssh user@machine_A -p 38935"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.