Host A wants to ssh into Host B which is behind a router. We don't have access to the router of Host B, so we can't do port forwading.

Which other alternatives are there for allowing Host A to ssh into Host B?

  • Quick comment, there is something called reverse SSH, maybe this could be of help to you? Reverse SSH means you ssh from host B to host A and reverse the connection, you can SSH this way – Maarten Mar 8 '16 at 22:33
  • @MaartenOlijve Can you please give an example with working commands? – ferit Mar 8 '16 at 23:06

One alternative that I've used for this purpose is to set up a VPN with an access point somewhere reachable by both Host A and Host B, i.e. somewhere on the internet. I suggest looking into OpenVPN and its examples. This way you can virtualize a network through which you can access any other hosts connected as if they were on the same network.

OpenVPN is pretty powerful, so providing a step-by-step guide would be beyond the scope of this answer.

  • 1
    This is also known as a "jump server" - and the only way to get around the lack of port forwarding, as far as I am aware, +1 – Sam3000 Mar 8 '16 at 21:54

There is one more alternative. Give host B regular IP address. Not NATTing, no RFC1918 IPs. Just a normal IP. Then (firewall rules allowing) everyone can ssh directly to host B.

  • Can you explain how? – ferit Mar 8 '16 at 23:00
  • Log in on host A (e.g. your own desktop) and type ssh hostB.domainfromB.tld. That should just work. It only gets harder if firm B adds firewalls, or does not give B a direclty reachable IP. Then you need to work around these barriers. (And for hosts B which are at home there often is such a barrier in the form or NAT, caused by us running out of IP v4 addresses and ugly workarounds. This is temporarily though. IPv6 and a much bigger IP pool has been introduced a few decades ago and is slowly getting implemented). – Hennes Mar 9 '16 at 6:50
  • So you mean ssh public_ip.private_ip ? Do I need to tell, Host B is also a personal computer under a router, there is no firm. – ferit Mar 10 '16 at 3:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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