首页 > 解决方案 > AWS 在私有子网中的 EC2 实例之间进行 ssh 的最佳方法

问题描述

我已将 NAT 和堡垒设置为使用 SSH 转发登录:

ssh-add -K keyfile.pem
ssh -A ec2-user@bastionhost
ssh ec2-user@privateSubnetServer

此时在私有子网中的主机之间处理 ssh 和用户的最佳方法是什么?

我得到:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

尝试以传统的 linux 方式进行操作时。如果我使用 AWS 创建的密钥对,我可以找到它们。

此时我无法设置或连接到目录服务。

标签: amazon-web-servicesamazon-ec2ssh

解决方案


Host bastion.ip.address
       User ec2-user
       IdentityFile ~/.ssh/bastionkey.pem
       CheckHostIP no

Host private.subnet.ip
       User ec2-user
       IdentityFile ~/.ssh/bastionkey.pem
       ProxyCommand ssh ec2-user@bastion.host.ip -W %h:%p

推荐阅读