Duc*_*een 5 ssh authentication key-authentication
我有一个私钥文件的文本。我想通过 ssh 连接到其他节点,但我所在的网关没有为我提供文件系统访问权限。如何将密钥的文本表示而不是带有它的文件传递给 ssh 客户端?
听起来您实际上并不需要将密钥存储在堡垒上,但实际上只需要连接到另一侧的某些东西。如果确实如此,并且只要您连接的 SSH 服务器没有阻止它,您应该能够使用 OpenSSH 的 ProxyCommand。在以下示例中,堡垒是您用来访问远程网络的外部主机。
ssh -o ProxyCommand "ssh bastion.example.com -W %h:%p" internal.example.com
Run Code Online (Sandbox Code Playgroud)
由于这并不容易输入,我建议将其放入您的 ${HOME}/.ssh/config 中,如下所示:
Host internal.example.com
User username
Hostname internal.example.com
ProxyCommand ssh bastion.example.com -W %h:%p
Run Code Online (Sandbox Code Playgroud)
如有必要,主机名可以替换为 IP 地址。