Install SSM Agent on Ubuntu AWS EC2 Instance

SSM agent is installed by default on the latest Ubuntu images, so first verify whether the SSM agent is already installed by executing the following command.

sudo snap list amazon-ssm-agent

if the above command returns error: no matching snaps installed then proceed with installing the SSM agent.

Pre-requisite

Attach the following IAM policies to the IAM role assigned to the EC2 instance.

  • AmazonSSMManagedInstanceCore - For SSM agent connectivity
  • CloudWatchAgentServerPolicy - For cloudwatch agent

Manual installation

Execute the following commands in the EC2 instance to install SSM agent

sudo snap install amazon-ssm-agent --classic

Post install verification steps

Make sure SSM agent installed properly by running

sudo snap list amazon-ssm-agent

To check the status of the agent.

sudo snap services amazon-ssm-agent

Start the service manually if the previous command returned amazon-ssm-agent is stopped, inactive, or disabled.

sudo snap start amazon-ssm-agent

Enable AWS System manager Quick Setup (Optional)

Do the following optional steps to keep the SSM agent up to date.

  1. Open AWS Systems Manager console https://console.aws.amazon.com/systems-manager/home
  2. Click Quick Setup in the left navigation
  3. If this is first time you are using this then select the region and click Get started
  4. Click Create under the Host Management
  5. Select the the required checkboxes under Systems Manager
  6. Select the required region and instance options
  7. Click Create

Troubleshoot SSM Manager connectivity

Ref