Launching Ubuntu EC2 Instance Session timeout / Login failed

Viewed 265

Step 1: Select to Launch Instance ( using free tier )

Image used to launch instance

Step 2: After process is completed updated the inbound rules as well as per below snap Inbound rules

From putty facing Session Timeout Issue when I'm trying to access using browser based SSH or PuTTY nothing is working This is common for all images of Ubuntu which I've tried & faced. Even tried to applied Elastic IP as well.

enter image description here

BUT where as it's not same case for Amazon's Linux Image. Works flawlessly well.

Can somebody help me what could be going wrong here or any post launch requisites I'm missing.

2 Answers

Based on your screenshot, you are using EC2 Instance Connect to login to your newly-created Ubuntu instance. This is a separate feature of AWS which mainly uses Identity and Access Management (IAM) policies instead of SSH keys.

While Alexander's answer is very useful for troubleshooting access to EC2 instances using SSH keys, it does not exactly apply to EC2 Instance Connect when using its browser client. Please refer to this document instead for all the steps required to setup a EC2 Instance Connect for an EC2 instance.

At your EC2 management console:

  1. On Instances page, make sure that the instance state is "running",
  2. Look the instance log at the Instances page (Actions | Instance Settings | Get system log). If it's empty, then the instance has not started properly. You may try Actions | Instance State | Start or Actions | Instance State | Reboot),
  3. Look at the Network interfaces page. It should have an entry for your new instance. If it has only IPv4 or IPv6 address, make sure that you have the corresponding IP address type,
  4. Make sure that your instance belongs to the security group for which you created the inbound rule,
  5. Although, the inbound rules SSH TCP 22 0.0.0.0/0 and All traffic All All 0.0.0.0/0 already allow any IPv4 to connect to port 22, so you didn't need to add your IP; so, make sure that your instance belongs to any security group and that group accepts SSH connections!
  6. I presume, you use the key pair set for the new instance and the login ubuntu, though the authentication stage is not reached,
  7. The connection command (from Linux console, you'll have to adapt it to Putty) is ssh -l ubuntu -i ~/.ssh/your_key_chosen_at_instance_launch.pem xx.xx.xx.xx, where xx.xx.xx.xx is the instance's IPv4.

Having checked all of the above, I was able to create and successfully connect to an t2.micro instance with Ubuntu 18.04 (LTS). Bear in mind that a t2.micro instance takes several minutes to launch.

P.S. It is also possible that your provider blocks the port 22. Then read this answer to change the default SSH port on newly launched instance: https://stackoverflow.com/a/33612991/6632736.

Related