在命令行中将 SSH ForwardAgent 和 ProxyJump 与 IdentityFile 结合使用

Mis*_*erZ 12 linux ssh proxy command-line

我在 SSH 中使用了新的 ProxyJump 选项。我在使用代理的 IdentityFile 时遇到问题。

示例 SSH 配置:

Host proxy
     HostName 1.0.0.1
     User foo
     Port 1234
     Identityfile ~/.ssh/mykey.id_rsa

Host target
     HostName 1.0.1.1
     User bar
     Port 5678
     Identityfile ~/.ssh/mykey.id_rsa
     ProxyJump proxy
     ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)

示意图:

            ssh          ssh
localhost ------> proxy ------> target
             ^             ^
           using         using
           mykey         mykey
Run Code Online (Sandbox Code Playgroud)

在此配置中使用 ssh 命令可以解决:

ssh target
Run Code Online (Sandbox Code Playgroud)

我试图在没有配置文件的情况下执行此操作,但它不起作用:

ssh -i ~/.ssh/mykey.id_rsa -AJ foo@1.0.0.1:1234 bar@1.0.1.1:5678
Run Code Online (Sandbox Code Playgroud)

我找不到-i为 ProxyJump 主机和目标主机指定 IdentityFile以使其工作的方法。

这有效:

ssh -i ~/.ssh/mykey.id_rsa -AJ proxy bar@1.0.1.1:5678
Run Code Online (Sandbox Code Playgroud)

是否有使用的一种方式-i-A-J-o标志来做到这一点?

Jak*_*uje 7

据我所知,你不能用新的跳跃魔法来做到这一点。但它应该与“旧”代理命令一起使用:

ssh -i ~/.ssh/mykey.id_rsa -Ao ProxyCommand="ssh -i ~/.ssh/mykey.id_rsa -W %h:%p -p 1234 foo@1.0.0.1" -p 5678 bar@1.0.1.1
Run Code Online (Sandbox Code Playgroud)