【问题标题】:SSH Jump Host WITHOUT Agent Forwarding无代理转发的 SSH 跳转主机
【发布时间】:2017-06-04 13:08:32
【问题描述】:

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

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

我怎么可能从我的机器 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

它不工作,因为它试图用 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.

【问题讨论】:

标签: authentication ssh server openssh agent


【解决方案1】:

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

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

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

另一个想法可能类似于ssh -t jump ssh server。这样,您登录 J 并从那里登录 S,几乎与您预期的一样。

【讨论】:

  • 没错。我已经阅读了更多内容,您是正确的。我试图避免代理转发,因为这是不好的做法并且目前不安全。与“ssh -t jump ssh server”相同,因为它在跳转服务器中运行另一个 ssh 进程,如果攻击者可以访问机器,他们可以破坏 ssh 二进制文件并仍然获得访问权限。谢谢!我现在会坚持将它们的密钥保留在我的主机上并使用 ProxyCommand :)
猜你喜欢
  • 2018-12-01
  • 2012-08-20
  • 2018-10-07
  • 1970-01-01
  • 2017-03-31
  • 2015-07-09
  • 1970-01-01
  • 2017-08-22
  • 2014-07-14
相关资源
最近更新 更多