How do I install AWS Systems Manager Agent (SSM Agent) on an Amazon EC2 Linux instance at launch?

Last updated: 2019-12-12

How do I install AWS Systems Manager Agent (SSM Agent) on an Amazon Elastic Compute Cloud (Amazon EC2) Linux instance at launch?

Short Description

By default, SSM Agent is installed on Amazon Linux based AMIs dated 2017.09 or later. SSM Agent is also installed, by default, on Amazon Linux 2, Ubuntu Server 16.04, and Ubuntu Server 18.04 LTS AMIs.

You must manually install SSM Agent on Amazon EC2 instances created from other versions of Linux AMIs, including non-base images such as Amazon Elastic Container Service (Amazon ECS) optimized AMIs. You can install SSM Agent by adding user data to an Amazon EC2 Linux instance before the launch.

Before installing SSM Agent, review the following information:

Resolution

1.    Create an IAM instance profile to use with SSM Agent.

2.    Follow steps 1 through 5 at Launch an Instance Using the Launch Instance Wizard.

3.    On the Configure Instance Details page, in the IAM role drop-down list, select the instance profile you created in step 1.

4.    On the Configure Instance Details page, expand Advanced Details.

5.    For User data, choose As text. In the User data box, enter information according to your Linux distribution requirements.

Amazon Linux 2, RHEL7, and CentOS 7 (64 bit)

#!/bin/bash
cd /tmp
sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent

Amazon Linux, CentOS 6 (64 bit)

#!/bin/bash
cd /tmp
sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
sudo start amazon-ssm-agent

Ubuntu 16 (Deb Installer), Debian 8 and 9

#!/bin/bash
mkdir /tmp/ssm
cd /tmp/ssm
wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb
sudo dpkg -i amazon-ssm-agent.deb
sudo systemctl enable amazon-ssm-agent

Ubuntu 14 (Deb installer)

#!/bin/bash
mkdir /tmp/ssm
cd /tmp/ssm
wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb
sudo dpkg -i amazon-ssm-agent.deb
sudo start amazon-ssm-agent

Suse 12

#!/bin/bash
mkdir /tmp/ssm
cd /tmp/ssm
wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
sudo rpm --install amazon-ssm-agent.rpm
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent

For more information, see User Data and the Console.

6.    Finish adding other parameters, such as storage, tags, and security groups.

7.    Launch your instance.