How to SSH into your EC2 instance

Day4 EC2-Part-2

How to SSH into your EC2 instance
Play this article

How to SSH into your EC2 instance: Step-by-Step

Linux and Mac OS

Introduction:

SSH (Secure Shell) is a widely used protocol that allows you to securely connect to your Amazon Elastic Compute Cloud (EC2) instances. SSH provides a secure channel for accessing and managing your EC2 instances remotely. In this article, we will walk you through the step-by-step process of SSHing into your EC2 instance.

Step 1:

Ensure Your EC2 Instance is Running: Before you can SSH into your EC2 instance, make sure it is in the "running" state. Log in to the AWS Management Console and navigate to the EC2 service. Check the status of your EC2 instance and ensure it is running.

Step 2:

Obtain the Public IP Address or DNS Name: To establish an SSH connection, you need the public IP address or DNS name of your EC2 instance. In the EC2 dashboard, select your instance and locate the "Public IP" or "Public DNS (IPv4)" field in the instance details.

Step 3:

Set Permissions for Your Private Key File: For security reasons, you need to restrict the permissions of your private key file. In your terminal or command prompt, navigate to the directory where the private key file is located and run the following command:

ls
chmod 400 your-private-key.pem

Step 4:

Connect to Your EC2 Instance: In your terminal or command prompt, run the SSH command with the following syntax:

ssh -i your-private-key.pem ec2-user@public-ip-or-dns

Step 5:

Confirm the Connection: If everything is set up correctly, you should now be connected to your EC2 instance via SSH. You will see a command prompt indicating a successful connection.

Example:

[ec2-user@ip-XX-XX-XX-XX ~]$

That's it! You have successfully SSHed into your EC2 instance using your existing key pair. Now you can execute commands and interact with your EC2 instance through the terminal or command prompt.

Thank you, and Happy Learning!!

Did you find this article valuable?

Support awscloudlab by becoming a sponsor. Any amount is appreciated!