【问题标题】:SSH tunnel in .ssh/config with public key on second leg.ssh/config 中的 SSH 隧道,第二段带有公钥
【发布时间】:2022-01-27 11:34:48
【问题描述】:

我想通过 Ubuntu20.04 服务器 U2 访问 Ubuntu20.04 服务器 U1,因为 U1 位于防火墙后面,来自带有 BugSur 的 MacBook。从 U2 到 U1 的 SSH 使用公钥完成,无需密码。我使用密码到达U2,但下一步总是要求输入密码(我现在不记得了)。我见过this question 并在MacBook 的.ssh/config 中尝试过这样的事情:

Host U2
    HostName accessible.uni.com
    User me
    # PreferredAuthentications publickey
    ForwardX11 yes

Host U1
    HostName behind_firewall.uni.com
    User me
    # PreferredAuthentications publickey
    # IdentityFile /home/me/.ssh/id_rsa.pub
    ProxyJump U2
    ForwardX11 yes

并运行ssh U1 输入U2 的密码,但随后要求输入U1 的密码。如何让它在第二个 ssh 上免密码运行?

【问题讨论】:

  • 你可以使用RemoteCommand Example
  • 您能否在笔记本电脑上运行身份验证代理,将您的密钥加载到代理中并使用-A 选项转发连接?

标签: ssh openssh public-key


【解决方案1】:

您可以使用远程命令。一旦它成功连接到 U2,它将执行命令 ssh U1。

Host U1
    HostName accessible.uni.com
    User me
    # PreferredAuthentications publickey
    ForwardX11 yes
    RemoteCommand ssh U1

【讨论】:

  • 谢谢!它适用于ssh -t U1,或者如果将RequestTTY force 添加到您的定义中。而U1必须在U2.ssh/config中定义。
【解决方案2】:

在这种情况下,显然带有ProxyJump 的隧道的每一段都希望通过来自 MacBook 的密钥(或密码)进行身份验证。因此,使用此选项有必要制作一个公钥并将其添加到每台计算机的authorized_keys,它应该通过无密码传递。

【讨论】:

    猜你喜欢
    • 2017-08-04
    • 2013-11-17
    • 2020-06-21
    • 2021-10-29
    • 1970-01-01
    • 2013-09-10
    • 2020-07-31
    • 2019-11-20
    • 2019-08-07
    相关资源
    最近更新 更多