Sunday, August 2, 2015

networking - How can access a server (SSH access) situated under 2 layer of private network from a PC having public IP?



I need to access (SSH) my client's server (Ubuntu Server 18.04) to provide support. But the server in client location is situated in private network.




I could have connected with port forwarding in client's router but even they got private IP from ISP. So if I want to connect to the server I need to arrange port forwarding in both client's router and their ISP's router or I need to ask my client to buy a public IP.



Is there any solution to overcome this situation (installing a software/package in server, using reverse proxy server, using something like reverse tcp payload etc) so that they don't have to buy public IP or port forward at ISP's router?



Please note that I have public IP, so it is possible to directly reach my PC from the server. Below file is a image containing visual representation of client's network.



https://file.io/1DIu2I



Any help would be really appreciated.



Answer



What you need is Reverse SSH, a term used to create a secure tunnel from server A to your machine B. Note that this connection has to be initiated from the server A. Basically something like:




ssh -R 3011:localhost:22 user@B




B is your machine in case. Since you mentioned that you have a public IP, the server can access your machine. Once the authentication is successful, there will be a secure tunnel through which you can ssh back into the server A.





ssh -p 3011 user@localhost




By first look, it might seem that you are accessing your own machine (localhost) but you actually are accessing the server A through the tunnel created in first step. You can read more about this at: https://blog.devolutions.net/2017/3/what-is-reverse-ssh-port-forwarding which also mentions some additional flags which are not necessary, but good to know in some cases.



PS. The link to gofile.io is not accessible


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...