简体   繁体   English

AWS Ubuntu EC2 实例无法通过 SSH 连接

[英]AWS Ubuntu EC2 Instance won't connect over SSH

Today I tried creating some EC2 instances using Ubuntu AMIs as I was following along with a course.今天,我在学习课程时尝试使用 Ubuntu AMI 创建一些 EC2 实例。 I've always used Amazon Linux AMIs but the instructor was using Ubuntu so I thought I would do the same.我一直使用 Amazon Linux AMI,但讲师使用的是 Ubuntu,所以我想我也会这样做。

I created a new PEM file with the instance, and I chose the defaults as I went through the instance wizard in console.我用实例创建了一个新的 PEM 文件,并在控制台中浏览实例向导时选择了默认值。 Also I had cleared out all previous VPCs and instances from a previous course, and started with a new default VPC.此外,我还清除了以前课程中所有以前的 VPC 和实例,并从一个新的默认 VPC 开始。 Everything spun up without issue.一切都毫无问题地旋转起来。

I changed the permissions on the new PEM and tried to SSH in using ssh -i PEMFILE ubuntu@IPADDRESS It did the normal asking to add the address into known_hosts and then logged out.我更改了新 PEM 的权限并尝试使用ssh -i PEMFILE ubuntu@IPADDRESS进行 SSH 它正常要求将地址添加到 known_hosts 然后注销。 I issued the command again and it immediately comes back Connection Closed .我再次发出命令,它立即返回Connection Closed

I tried looking at all my VPC settings (NACLs, Routing, IGW, etc...) and security group inbound and outbound rules which were set for SSH 22 0.0.0.0/0 in and everything out.我尝试查看我所有的 VPC 设置(NACL、路由、IGW 等)以及为 SSH 22 0.0.0.0/0输入和所有输出设置的安全组入站和出站规则。 I terminated and destroyed everything again including VPC and tried from scratch again.我再次终止并销毁了包括 VPC 在内的所有内容,并再次从头开始尝试。 Same issue.同样的问题。 I checked the key SHA to make sure it was good and it was.我检查了密钥 SHA 以确保它是好的。 I then decided to spin up an Amazon Linux Instance using the same key and VPC.然后我决定使用相同的密钥和 VPC 启动一个 Amazon Linux 实例。 Right in with no issue under ec2-user user.在 ec2-user 用户下没有问题。 Spun up a CentOS instance, same key and VPC.启动一个 CentOS 实例,相同的密钥和 VPC。 Right in as well under centos user.就在centos用户下。

I'm scratching my head on why only the Ubuntu AMI won't let me SSH in?我正在挠头,为什么只有 Ubuntu AMI 不让我通过 SSH 进入?

Thanks in advance for any help!在此先感谢您的帮助!

I must have been doing something wrong because I just spun up another instance and without issue it "stayed" connected.我一定是做错了什么,因为我刚刚启动了另一个实例并且没有问题它“保持”连接。 I'm in without issue and it doesn't immediately log me out as soon as I connect.我没有问题,并且在我连接后它不会立即将我注销。 I'm still not sure what I could have been doing to cause that, but I'm in and working now.我仍然不确定我会做些什么来导致这种情况,但我现在正在工作。 Thanks for the suggestions!感谢您的建议! I would still love to hear from anyone that would know what the issue could have been.我仍然很乐意听取任何知道问题可能是什么的人的意见。

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

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