Tuesday, October 26, 2021

How to use the Ubuntu terminal to connect to an AWS EC2 instance

Must Read

Are you using Ubuntu or any other Linux such as CentOS, Fedora, Mint, and want to connect to Amazon cloud running ec2 Instance, then here are the steps to follow.

Use Ubuntu Distro to Connect Amazon ec2 Instance
When we create an Amazon Elastic Compute Cloud Instance of Linux or Windows, the system automatically creates a Private key file in .pem format. In case you haven’t created one, then follow our tutorial to generate a new Keypair.

Contents

1. Download Keypair
If you have a fresh Ubuntu system then you can download the key pair assigned to your instance from Amazon Management Interface.

2. Open Command terminal
If you are using a graphical Ubuntu then simply press the Ctrl+Alt+T shortcut to open the Terminal app. Whereas the CLI server users are already on the command line.

Go to your Ec2 Dashboard.
Click on the “Instance” option from the left panel.
After that select the Instance of Linux or Windows that you want to connect remotely.
As you select it, some information will be revealed, go to the “Key pair name” section and click on the AWS Ec2 to download the assigned key pair.
Download AWS EC2 Key pair

3. Switch to the directory where the key is saved
On your Ubuntu Terminal switch to the directory where you have saved the downloaded Pem private key of your Instance.

For example, if it is in the Downloads directory, then simply switch to that:

cd Downloads 4. Change Key Permission
For security reasons, we have to change the permission for the key so that it can only be readable by the user and removes all other permissions.

chmod 400 AWS EC2.pem 5. Connect to your Instance using Publix Ip-address or DNS
Now, from your Ec2 Instance page either note down the public ipv4 IP address or DNS

Copy Public Ip adress or DNS Syntax to connect

ssh -i path-to-key ec2-user@ip-address
Example: ssh -i ~/Downloads/AWSEC2.pem ec2-user@65.0.95.33
or

ssh -i ~/Downloads/AWSEC2.pem ec2-65-0-95-33.ap-south-1.compute.amazonaws.co
Connect AWS ec2 from Ubuntu Set an environment variable for the Private PEM key
Pro Tip: On Linux, you can set an environment variable for your key so that we can use it globally without specifying its path again and again:

News Summary:

  • How to use the Ubuntu terminal to connect to an AWS EC2 instance
  • Check all news and articles from the latest Security news updates.
Disclaimer: If you need to update/edit this article then please visit our help center. For Latest Updates Follow us on Google News

More Articles Like This

Latest News