大网数据广告活动
服务器运维问答

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

· 52CE 我爱测

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 go…

问题原文

原帖链接 · Tamal Biswas · CC BY-SA 4.0

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.

已采纳解答

原帖链接 · sla3k · CC BY-SA 4.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-11-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。