我的跳转服务器和最终主机都在非默认的22端口上运行。
根据https://wiki.gentoo.org/wiki/SSH_跳_主机的说法,我试过ssh -J user1@host1:port1 user2@host2 -p port2
或ssh -J user1@host1:port1 user2@host2:port2
我被提示输入跳转服务器密码,然后它们都因错误而失败。
channel 0: open failed: administratively prohibited: port forwarding is disabled
stdio forwarding failed
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
那我该怎么做呢?
发布于 2022-06-08 09:58:51
手册页说-J
选项的格式是-J [user@]host[:port]
,所以-J user1@host1:port1
看起来是对的:
-J [user@]host[:port]
连接到目标主机,首先通过与跳转主机建立ssh连接,然后从那里建立到最终目的地的转发。可以用逗号字符分隔多个跳转跳。这是指定ProxyJump配置指令的快捷方式。
但基于该错误,您的问题似乎不是端口规范,而是中间主机不允许端口转发的事实,而且-J
需要这样做。
如果不可能更改这一点,但您确实信任跳转主机,则可以连接到跳转主机,并在那里运行另一个SSH客户端来打开到最终目标主机的连接:
ssh user1@host1:port1 'ssh user2@host2:port2'
(或者使用ssh -t
)
https://unix.stackexchange.com/questions/705382
复制相似问题