DEV Community

Madhav Nakra
Madhav Nakra

Posted on

Configuring AWS CLI on Ubuntu for Local Machine ☁️🐧

When people start learning AWS, they usually focus only on installing the AWS CLI.
But installing it is just the first step.

To actually interact with AWS services from your Ubuntu machine, you also need to configure AWS credentials properly.

In this guide, we’ll go through the complete setup process for AWS CLI on Ubuntu β€” from installation to configuration and verification.

Why AWS CLI?

AWS CLI allows you to manage AWS services directly from your terminal.

You can:

  • Launch EC2 instances
  • Upload files to S3
  • Configure IAM
  • Manage EKS clusters
  • Automate cloud operations using scripts

Instead of clicking through the AWS Console every time, AWS CLI helps automate everything efficiently.


Step 1: Update Packages

First, update your system packages:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

This ensures your package manager has the latest repository information.


Step 2: Install Required Dependencies

Install curl and unzip:

sudo apt install unzip curl -y
Enter fullscreen mode Exit fullscreen mode

These tools are required to download and extract the AWS CLI installer.


Step 3: Download AWS CLI v2 Installer

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Enter fullscreen mode Exit fullscreen mode

This downloads the latest AWS CLI v2 package for Ubuntu/Linux systems.


Step 4: Unzip the Installer

unzip awscliv2.zip
Enter fullscreen mode Exit fullscreen mode

This extracts the installation files.


Step 5: Run the Install Script

sudo ./aws/install
Enter fullscreen mode Exit fullscreen mode

AWS CLI will now be installed on your machine.


Step 6: Verify Installation

Check whether AWS CLI is installed successfully:

aws --version
Enter fullscreen mode Exit fullscreen mode

Example output:


Step 7: Configure AWS CLI

Now comes the important part β€” configuration.

Run:

aws configure
Enter fullscreen mode Exit fullscreen mode

You’ll be asked for:

AWS Access Key ID
AWS Secret Access Key
Default region name
Default output format
Enter fullscreen mode Exit fullscreen mode

Example:

AWS Access Key ID [None]: AKIAXXXXX
AWS Secret Access Key [None]: ********
Default region name [None]: ap-south-1
Default output format [None]: json
Enter fullscreen mode Exit fullscreen mode

You can generate Access Keys from:

AWS Console β†’ IAM β†’ Users β†’ Security Credentials β†’ Create Access Key


Step 8: Verify Configured Profiles

To check configured AWS profiles and settings:

aws configure list
Enter fullscreen mode Exit fullscreen mode

This helps verify whether your credentials and region are configured correctly.


Step 9: View Stored Credentials

AWS stores credentials locally inside the .aws directory.

Check credentials file:

cat ~/.aws/credentials
Enter fullscreen mode Exit fullscreen mode

Check config file:

cat ~/.aws/config
Enter fullscreen mode Exit fullscreen mode

Understanding the Files

credentials file

Stores:

  • Access Key ID
  • Secret Access Key

Example:

[default]
aws_access_key_id = XXXXX
aws_secret_access_key = XXXXX
Enter fullscreen mode Exit fullscreen mode

config file

Stores:

  • Default region
  • Output format

Example:

[default]
region = ap-south-1
output = json
Enter fullscreen mode Exit fullscreen mode

Important Security Tip ⚠️

Never share:

  • Access Key ID
  • Secret Access Key
  • .aws/credentials file

Also, add .aws/ to .gitignore if you're working inside projects.


Conclusion

Installing AWS CLI is easy, but properly configuring it is what actually enables you to work with AWS services from your local Ubuntu machine.

Once configured, you can automate cloud operations directly from the terminal and integrate AWS into scripts, CI/CD pipelines, and DevOps workflows.

If you're starting your cloud or DevOps journey, AWS CLI is one of the most essential tools to learn πŸš€

Top comments (0)