Today I tried creating some EC2 instances using Ubuntu AMIs as I was following along with a course. I've always used Amazon Linux AMIs but the instructor was using Ubuntu so I thought I would do the same.
I created a new PEM file with the instance, and I chose the defaults as I went through the instance wizard in console. Also I had cleared out all previous VPCs and instances from a previous course, and started with a new default 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. I issued the command again and it immediately comes back 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. I terminated and destroyed everything again including VPC and tried from scratch again. Same issue. I checked the key SHA to make sure it was good and it was. I then decided to spin up an Amazon Linux Instance using the same key and VPC. Right in with no issue under ec2-user user. Spun up a CentOS instance, same key and VPC. Right in as well under centos user.
I'm scratching my head on why only the Ubuntu AMI won't let me SSH in?
Thanks in advance for any help!
ssh -vvv
to turn on detailed logging. – John Rotenstein