问题原文
原帖链接 · sbat · CC BY-SA 3.0
I'd like to setup three hosts:
- HostC - destination host. You can login to it as
ssh UserC@HostCwith private key. - HostB - "ambassador/proxy" for HostC. When you ssh to HostB (simply as
ssh UserB@Bwith 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@HostBand - 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
