没有代理转发的 SSH 跳转主机

Car*_*ndo 4 authentication ssh openssh agent server

虽然是一个简单的问题,但我已经搜索了几天没有成功。

M = My machine 
J = Jump Host
S = Server

Jump Host has my public key on authorized_keys.
Server has J's public key on authorized_keys.

Allowed connections (due to key authentication):
M -> J
J -> S
Run Code Online (Sandbox Code Playgroud)

我怎么可能从我的机器 ssh 进入 S?

我目前的配置是:

host jump
  user root
  HostName x.x.x.x

host server
  user root
  HostName x.x.x.x
  port 22
  ForwardAgent no
  ProxyCommand ssh jump -W %h:%p
Run Code Online (Sandbox Code Playgroud)

当它尝试使用 M 的密钥登录时它不起作用。

这是 ssh 日志

debug1: Host 'x.x.x.x' is known and matches the ECDSA host key.
debug1: Found key in /Users/xxxxx/.ssh/known_hosts:1542
...
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/xxxxx/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/xxxxx/.ssh/id_dsa
debug1: Trying private key: /Users/xxxxx/.ssh/id_ecdsa
debug1: Trying private key: /Users/xxxxx/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
Killed by signal 1.
Run Code Online (Sandbox Code Playgroud)

mic*_*has 6

是的。当然,它会尝试使用 M 的密钥登录。你并没有真正从 J 连接到 S。

第一个 ssh 连接是从 M 到 J。这个连接只是设置了一些转发。第二个 ssh 连接使用第一个 ssh 建立的转发直接从 M 到 S。- 没有机会在 J 上使用钥匙。

您可能会使用ssh -A jump ssh-add将 J 的密钥添加到您的代理。那么您的设置应该可以正常工作。

另一个想法可能类似于ssh -t jump ssh server. 通过这种方式,您可以登录 J,然后从那里登录 S,这与您的预期非常相似。