通过 SSH 通过堡垒进入 EC2 时遇到特殊情况,其中 ProxyCommand 工作,而 ProxyJump 失败。为了将本地代码编辑器(VS Code)与实例连接起来,需要通过一个 ProxyCommand(RemoteCommand 只是返回堡垒主机目录)。
我的 .ssh/config 的内容
#Works
Host ec2-prod
HostName 10.249.63.1
User bsaunders1
RemoteCommand ssh 10.0.2.140
RequestTTY yes
IdentityFile ~/.ssh/my_idfile
#Fails with permission denied public key bsaunders1@10.0.2.140
Host bastion-prod
HostName 10.249.63.1
User bsaunders1
IdentityFile ~/.ssh/my_idfile
RequestTTY yes
Host ec2-prod-v2
HostName 10.0.2.140
User bsaunders1
ProxyJump bastion-prod
我能说的最好的是,一旦 ssh'ing 到堡垒主机,就会加载单独的密钥,然后用于授权进一步 ssh 进入特定的 EC2 实例。无法弄清楚如何在遥控器中指定利用密钥,将尝试下载密钥本身并关闭它,但非常感谢您提供更详细的理解帮助!