首页 文章

Amazon EC2从公共实例ssh到vpc中的私有实例

提问于
浏览
-1

我是Amazon EC2的新手,我想从公共实例使用ssh实用程序访问私有实例 .

这是我的设置 .

instance list in the vpc
instance list in the vpc

private instance's information
private instance's information

private instance's inbound rule of security group
private instance's inbound rule of security group

ssh connection timedout
ssh failed

即使我无法ping私有实例 . 为什么无法访问私有实例?

EDIT: Added routing table information
enter image description here

enter image description here

顺便说一句,对不起,我不知道如何在控制台视图中更改语言 .

再次编辑:使用ssh从pem文件连接到公共实例的私有实例的私有ip .

enter image description here

enter image description here

1 回答

  • 2

    Use the Private IP address (从 10. 开始 - 从您的图片中,可能是 10.0.1.101 )从公共实例连接到私有实例 - 您似乎正在尝试连接到公共IP地址,这将无法正常工作 .

    默认情况下禁用Ping,除非您在安全组中允许它,因此 do not use Ping to diagnose network configurations .

    如果您的 SSH 命令挂起,则表示没有网络连接 . 最常见的原因是安全组 . 暂时打开安全组中端口22的所有流量( 0.0.0.0/0 )并测试其是否有效 . (如果实例位于私有子网中,则无法从VPC外部访问它!)

    除非您的私有实例需要访问Internet,否则无需使用 NAT Gateway .

    您似乎正在尝试将SSH命令与.PPK文件一起使用,该文件不正确 - PPK files are only used for PuTTY . 对于SSH命令,请使用PEM文件 . 如果您不希望将密钥存储在公共(Web)实例上,请将Pageant与PuTTY一起使用并启用代理转发 . 见:How To SSH Hop With Key Forwarding from Windows

    其他提示:

    • 确保两个实例都在 same VPC

    • 您的私人安全组允许从 122.40.73.88/32 进行访问,这是一个公共IP地址 . 这不起作用,因为实例位于私有子网中 .

相关问题