DEV Community

Cover image for How To Install And Configure The AWS CLI On Linux OS
Shola Umakhihe
Shola Umakhihe

Posted on

How To Install And Configure The AWS CLI On Linux OS

The Amazon Web Service Command Line Interface(CLI) is the fastest and easiest way to connect to AWS services and products.

Some instances have the CLI pre-installed such as the Amazon Linux instances while instances like the Red Hat Linux don’t. In this article, I will show you how to install and configure the CLI in an instance.

You’ll need a secure shell connection (SSH), to your AWS instance account and then configure and install.

Pre-requisite: AWS account, SSH Access key, Linux OS installed computer, internet access and a stable mind.

STEP 1: Create an instance in your EC2

- Login to your AWS management console and navigate to EC2
- Create an EC2 with the Red Hat Linux AMI
- Select Network and security in the navigation pane, and enter key pairs
- Select Create Key Pair.
- Then, select the format of the file (. pem)
- Then, download
Enter fullscreen mode Exit fullscreen mode

STEP 2: Connect to your instance using SSH

- Open your terminal with Shift + Ctrl + T
- Navigate to your downloads or anywhere you must have downloaded the .PEM file with “cd downloads”
- Change the permission on it with chmod 400 <filename.pem>
- Go to your AWS management console, go instance.
- Select the the instance type
- By the description tab copy the IPv4 Public IP value.
- Go back to your terminal and run this command ssh -i labsuser.pem ec2-user@<public-ip> (replace <public-ip> with your IPv4 Public IP)
- Type “yes” at the prompt.
- Voila, connected sucessfully
Enter fullscreen mode Exit fullscreen mode

STEP 3: Install the AWS CLI on Red Hat Linux

Now that you have an active SSH connection to the Red Hat Linux instance running on Amazon EC2, next is to install AWS CLI.

- Run sudo yum install -y unzip
- Then, run curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o “awscliv2.zip”
- Then, unzip awscliv2.zip
- Then, sudo ./aws/install
- Verify that AWS CLI is now working by running the following command: aws help
- At the : prompt, type q to exit.
- You are set.
Enter fullscreen mode Exit fullscreen mode

STEP 4: Configure the AWS CLI to connect to your AWS Account

Time to connect your AWS account to your AWS CLI. Go to the active SSH session terminal window and run aws configure. At the prompt enter your AWS Access Key ID and AWS Secret Access Key

We are all set, now you can work on your EC2 instance and every other AWS service from your personal machine using your local terminal.

Top comments (0)