authentication - 无需代理转发的 SSH 跳转主机

标签 authentication ssh server openssh agent

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

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 的 key 登录。

这是 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.

最佳答案

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

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

您可以使用ssh -A跳转ssh-add将J的 key 添加到您的代理中。 那么你的设置应该可以正常工作。

另一个想法可能类似于ssh -t 跳转 ssh 服务器。这样您就可以登录到 J,然后从那里登录到 S,这与您的预期非常相似。

关于authentication - 无需代理转发的 SSH 跳转主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41748491/

相关文章:

ruby-on-rails - 在 Rails 中为新手创建登录的最佳方式是什么?

node.js - 在 Node.js Web 服务器中确定用户角色并授予 API 访问权限的正确方法是什么?

go - 使用 Golang os/exec 执行带有 args 的 ssh 命令会导致退出状态 127

c - 如何在 C 中将客户端的 IP 存储在数组中(套接字编程)

python - Django 检查服务器是否已经运行

authentication - 带有 Route::resource 的“auth”中间件

asp.net-mvc - 无法检索表单例份验证票证上的用户数据

ssh - 你如何在 Go 中使用 go.crypto/ssh 包来处理 StrictHostKeyChecking?

linux - 通过 ssh 运行 bash 脚本以启动激活器后,Travis-ci 不会退出

Java 和 Heroku