简体   繁体   English

AWS EC2-Ubuntu实例,SSH连接主机操作超时

[英]AWS EC2 - Ubuntu instance, SSH connect to host operation timed out

I am new to setting up virtual machines. 我是新建立虚拟机的人。 I created my first Ubuntu instance using AWS EC2. 我使用AWS EC2创建了我的第一个Ubuntu实例。 Everything seemed to check out until I tried connecting to it with ssh, as per instructions. 按照说明,一切似乎都在检查,直到我尝试使用ssh连接到它为止。

To provide some context, my app is called "smpapp". 为了提供一些上下文,我的应用程序称为“ smpapp”。 My computer is macOS High Sierra. 我的电脑是macOS High Sierra。 Naturally, my smpapp.pem file saved to ~/Downloads . 自然,我的smpapp.pem文件保存到~/Downloads First, I opened up the Terminal and set my working directory to Downloads with cd ~/Downloads . 首先,我打开终端并将工作目录设置为cd ~/Downloads Then I entered chmod 400 smpapp.pem , which didn't return any error, so I assume it was a success. 然后,我输入chmod 400 smpapp.pem ,它没有返回任何错误,因此我认为它是成功的。 Then, I entered ssh -i "smpapp.pem" ubuntu@ec2-XX-XX-XXX-XXX.us-east-2.compute.amazonaws.com (omitting public DNS numbers with Xs). 然后,我输入ssh -i "smpapp.pem" ubuntu@ec2-XX-XX-XXX-XXX.us-east-2.compute.amazonaws.com (用X省略公共DNS编号)。 It took awhile to process before spitting out, ssh: connect to host ec2-XX-XX-XXX-XXX.us-east-2.compute.amazonaws.com port 22: Operation timed out . 吐出一段时间后, ssh: connect to host ec2-XX-XX-XXX-XXX.us-east-2.compute.amazonaws.com port 22: Operation timed out进行了处理ssh: connect to host ec2-XX-XX-XXX-XXX.us-east-2.compute.amazonaws.com port 22: Operation timed out

Can someone explain the general problem to me and how I can fix it (methodically and in layman's terms)? 有人可以向我解释一般性问题以及如何解决(方法和外行术语)吗?

Could be a few things: 可能是几件事:

Does your ec2 instance have a public ip? 您的ec2实例是否具有公共IP? (if not, you might have to attach an elastic ip or put it in a public subnet) (否则,您可能必须附加一个弹性IP或将其放入公共子网中)

Is the security group attached to the ec2 instance allowing connections to port 22? 连接到ec2实例的安全组是否允许连接到端口22?

Is the ACL on the subnet allowing public connections to the subnet? 子网上的ACL是否允许公共连接到子网上?

Is your VPC configured to routetraffic through your IGW? 您的VPC是否配置为通过您的IGW路由流量?

Amazon offers step by step instructions on determining the issue, it could be for any reason of the above not being configured properly. 亚马逊会提供有关确定问题的分步说明,这可能是由于上述原因而导致的。 You can find step by step instructions on what do in the official amazon docs here . 您可以在此处找到有关官方亚马逊文档的逐步说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM