I have a device running Linux (Debian) installed at a remote location with internet access.

I can't modify the remote location's firewall, and the public IP address is dynamic.

How can I access this machine via SSH from outside the machine's LAN, without modifying the firewall to port-forward port 22 to the machine?

NOTE: I have a web-facing cloud server available with static IP address, and the remote device contacts this server every 5 seconds to retrieve configuration data. I could push a command to the device if necessary to initiate some sort of reverse SSH tunnel, but I'm not sure how to then utilize that tunnel from the server and/or my local desktop.

Having the ability to SFTP files to the device from either the cloud server or my local desktop would be a huge added bonus.

Thanks for any advice or suggestions on how to accomplish this!

  • Downvotes? Why?? – Ryan Griggs May 24 '17 at 17:07
  • Downvotes without comment can be assumed to be for one of the reasons listed in the downvote arrow hover text. – EEAA May 24 '17 at 18:23

Remote machine is A Your cloud server is B Your desktop/laptop is C

A initiates a SSH session w/ reverse tunnel to B. This opens a port on B's localhost, pointing back to port 22 on machine A. All traffic travels over this tunnel. Check the -R option to the ssh client.

From C you ssh into B, then ssh to the port on the localhost that is the B end of the SSH tunnel that A initiated.

  • Good answer. Any way to open a port on B where I could ssh "directly" from C to A, going through B? This would avoid necessity of two ssh connections... – Ryan Griggs May 24 '17 at 16:55
  • Yes, check the man page for SSH with the -R option, you can specify what IP to open on the remote (machine B) end. – ivanivan May 24 '17 at 17:06

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.