2
votes

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!

1
It's got to be a key mismatch.Rodrigo M
What is the username you used for the ubuntu instance?Ali
You can use ssh -vvv to turn on detailed logging.John Rotenstein
@RodrigoM I cleared out all keys before starting today and the key that I generated today when creating the initial ubuntu instances works without issue on the non-ubuntu instances.Adam Ayd
@Ali I used the username ubuntu, not ec2-userAdam Ayd

1 Answers

0
votes

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.