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

SSH Tunnel connect 2 Servers via third Server

· 52CE 我爱测

I have 3 Servers, A is a public accessable Server in the Internet. B Hosts a Webservice I want to access. C has access rights to connect to A and B. Now i want that if a Client D tries to access a special Port on A that he gets f…

问题原文

原帖链接 · mac.1 · CC BY-SA 3.0

I have 3 Servers, A is a public accessable Server in the Internet. B Hosts a Webservice I want to access. C has access rights to connect to A and B.

Now i want that if a Client D tries to access a special Port on A that he gets forwarded to B.

IP's and Ports

A:

  • 1.0.0.1:22 SSHD Server
  • 1.0.0.1:443 Public Port which i want to use

B:

  • 1.0.0.2:23 SSHD Server
  • 1.0.0.2:444 Webservice I want to access

C:

  • 1.0.0.3

D:

  • 1.0.0.4

Diagram:

  +------------+        +------------+
  | Client (D) +--------> Public (A) |
  +------------+        +-----^------+
                              |
  +----------------+    +-----------+
  | Webservice (B) <----+ Proxy (C) |
  +----------------+    +-----------+

Question:

What ssh tunnel Commands do i need to execute on C so that if i try to open 1.0.0.1:443 on D i get the service hosted on 1.0.0.2:444 ?

已采纳解答

原帖链接 · kasperd · CC BY-SA 3.0

On C you can run

ssh -fNR 1.0.0.1:443:1.0.0.2:444 [email omitted]

It will only work if you login as root user because 443 is a privileged port. Moreover it only works if sshd on A is configured with GatewayPorts set to yes or clientspecified. (The default is no and using yes cannot be recommended, so if you want to do it this way I recommend clientspecified).

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

资料来源与适用范围

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

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

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