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

Lesedauer: 3 Minute
0

I want to install the AWS Systems Manager Agent (SSM Agent) on my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance and have it start before launch.

Short description

By default, SSM Agent is installed on Amazon Linux Base Amazon Machine Images (AMIs) dated 2017.09 and later. SSM Agent is also installed by default on Amazon Linux 2 AMIs and Amazon Linux 2 ECS-Optimized Base AMIs. The latest Amazon EKS optimized AMIs install SSM Agent automatically.

You must manually install SSM Agent on Amazon EC2 instances created from other versions of Linux 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 dropdown 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 the information according to your Linux distribution requirements.

Amazon Linux 2, RHEL 7, 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

RHEL 8 and CentOS 8

#!/bin/bash
cd /tmp
sudo dnf 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

Note: Python 2 or Python 3 must be installed on your RHEL 8 or CentOS 8 instance for SSM Agent to work correctly. To verify that Python is installed, add the following command to the preceding command examples:

sudo dnf install python3

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.

For Windows, see How do I install AWS Systems Manager Agent (SSM Agent) on an Amazon EC2 Windows instance at launch?


Related information

Automating updates to SSM Agent

Installing and configuring SSM Agent on EC2 instances for Linux

Setting up AWS Systems Manager

Installing and configuring SSM Agent on EC2 instances for Windows Server

Why is my EC2 instance not appearing under Managed Instances in the Systems Manager console?

AWS OFFICIAL
AWS OFFICIALAktualisiert vor einem Jahr