How to Login/SSH to AWS EC2 linux instance? SSH

How to Login/SSH to AWS EC2 linux instance?

Use case

  1. Login/SSH to AWS Linux EC2 instance

Prerequisites

  • You already have a Linux EC2 instance running in AWS and port 22 is enabled for public access.
  • You must have a private key like mykey.pem (Privacy Enhanced Mail).
  • If you are using a Windows machine then SSH client should be installed. You can use Putty which is easy. You can download it from https://putty.org/.

SSH from Windows machine

Convert PEM to PPK file

When you install the putty you might already have puttygen installed. Hence, open it.

  1. Click on Load button
  2. Select the PEM file where you have saved in your local machine.
  3. Click Save Private Key button.
  4. Give a proper name and save it. It should save in .ppk format.

SSH from putty

  1. Now open the putty
  2. Select the Session category.
  3. On the Host Name (or IP address) field, type the ubuntu@yourIP if your ec2 instance is Ubuntu and ec2-user@yourIP if your ec2 instance is Amazon Linux AMI.
  4. Go to SSH category which is under Connection
  5. Expand to SSH after clicking + icon
  6. Click on Auth
  7. Click on Browse button
  8. Select the PPK file where you have saved earlier.
  9. Click open.
  10. You may see a small dialog to accept it if you are connecting first time. You must accept.

You should be able log in to ec2 instance.

SSH from Linux or Mac

  1. Locate to your PEM file.
  2. Give read permission to your PEM file with the command: sudo chmod 400 mykey.pem
  3. Type: ssh -i mykey.pem ubuntu@yourIP
  4. You may need to accept if you are trying first time.

With this above step, you should be able to login/ssh to your ec2 instance.

Conclusion

We are able to access our ec2 instance. Now, we can start to work on our ec2 instance.


Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments