{"id":107000,"date":"2024-03-08T09:40:50","date_gmt":"2024-03-08T14:40:50","guid":{"rendered":"https:\/\/jumpcloud.com\/?p=107000"},"modified":"2024-04-10T13:15:37","modified_gmt":"2024-04-10T17:15:37","slug":"how-to-use-aws-cli-amazon-linux","status":"publish","type":"post","link":"https:\/\/jumpcloud.com\/blog\/how-to-use-aws-cli-amazon-linux","title":{"rendered":"How to Use the AWS CLI with Amazon Linux"},"content":{"rendered":"\n

Jump to Tutorial<\/a><\/p>\n\n\n\n

Amazon Web Services (AWS) provides a wide array of cloud computing solutions. Mastering the AWS Command Line Interface (CLI) is an essential skill for developers, system administrators, and cloud engineers working within its ecosystem. <\/p>\n\n\n\n

Amazon Linux, an open source Linux distribution provided by AWS, is optimized for running on AWS infrastructure, making it a popular choice for cloud-based applications. It\u2019s an example of how mastering the CLI will provide better control over the system and increase efficiency. This tutorial offers a detailed guide on how to use the AWS CLI on an Amazon Linux instance, covering installation, configuration, and various use cases.<\/p>\n\n\n\n

The AWS CLI is a powerful tool that enables users to interact with AWS services directly from the command line. It provides a consistent interface for controlling and automating AWS resources, streamlining the process of managing cloud infrastructure.<\/p>\n\n\n\n

For this tutorial, we need an active AWS account, at least one AWS EC2 instance, and basic knowledge of Linux command line operations.<\/p>\n\n\n\n

\n\n<\/figure>\n\n\n\n

Step 1: Connect to Your EC2 Instance<\/h2>\n\n\n\n

<\/p><\/div>

Note:<\/strong> \n

AWS Identity and Access Management (IAM) has multi-factor authentication<\/a> (MFA) features. It\u2019s advisable to enable MFA for your account.<\/p>\n <\/div><\/div><\/div><\/div>\n\n\n\n

This step assumes that you\u2019ve already provisioned at least one EC2 instance so you can use the terminal or a SSH client to connect to it.<\/p>\n\n\n\n

First, go to the Instance section in your AWS account.<\/p>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

Select the instance you want to connect to and select the Connect<\/strong> option from the menu.<\/p>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

Select the SSH client menu item and follow the instructions. <\/p>\n\n\n\n

<\/p><\/div>

Note:<\/strong> \n

AWS Systems Manager\u00a0Session Manager<\/a> should be used whenever possible to avoid exposing a direct IP to the open web. There are oo open inbound ports and no need to manage bastion hosts or SSH keys.<\/p>\n <\/div><\/div><\/div><\/div>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

When copying the ssh <\/strong>command, make sure you are in the correct directory so you can load your private key and log in to the server.<\/p>\n\n\n\n

If this is your first time logging in to the server, then you will receive a notice that the authenticity of the host can’t be established, so you need to type yes<\/strong> to proceed forward.<\/p>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

After this step, you are successfully logged into the instance.<\/p>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

Step 2: Configure Your Instance for CLI<\/h2>\n\n\n\n

It is a good idea to check for updates for your Amazon Linux instance.<\/p>\n\n\n\n

We can do so by running the following command:<\/p>\n\n\n\n

\n

sudo dnf update<\/p>\n<\/div><\/div>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

In our case, since we provisioned our instance recently there are no pending updates, but it is always good to check for security patches for your packages.<\/p>\n\n\n\n

Next, we need to check if AWS CLI is installed correctly. It\u2019s pre-installed on Amazon Linux so you can check its version by running the following command:<\/p>\n\n\n\n

\n

aws –version<\/p>\n<\/div><\/div>\n\n\n\n

\"tutorial<\/figure>\n\n\n\n

Next, we need to make sure we meet these prerequisites:<\/p>\n\n\n\n