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

SSH: fully transparent passthrough from A through B to C

· 52CE 我爱测

I'd like to setup three hosts: HostC - destination host. You can login to it as ssh UserC@HostC with private key. HostB - "ambassador/proxy" for HostC. When you ssh to HostB (simply as ssh UserB@B with UserB private key, without …

问题原文

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

I'd like to setup three hosts:

  • HostC - destination host. You can login to it as ssh UserC@HostC with private key.
  • HostB - "ambassador/proxy" for HostC. When you ssh to HostB (simply as ssh UserB@B with UserB private key, without any additional actions like ProxyCommand in the config), it should be full equivalent of sshing directly to HostC. Of course, HostB has private key needed to connect to HostC. I have full control over HostB itself.
  • HostA - host, from which we want to run ssh UserB@HostB and - via HostB - connect to destination HostC without even knowing beforehand about HostC.

There's almost the same questions here:

SSH from A through B to C, using private key on B

However, accepted answer there is to use ProxyCommand. This requires configuration on HostA, which is not desirable in my case.

Is such scenario at all possible? Thanks!

已采纳解答

原帖链接 · Andrew Schulman · CC BY-SA 3.0

In /etc/ssh/sshd_config on HostB, you could write something like

ForceCommand ssh HostC

maybe prececed by a Match operator to select on certain users or source hosts or IP addresses. See man sshd_config for more details.

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

资料来源与适用范围

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

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

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