Installing the SSM Agent
The Amazon EC2 Simple Systems Manager (SSM) agent processes Run Command requests and configures the instances that are specified in the request. Use the following procedures to install, configure, or uninstall the SSM agent.
Note
The source code for the SSM agent is available on GitHub so that you can adapt the agent to meet your needs. We encourage you to submit pull requests for changes that you would like to have included. However, Amazon Web Services does not currently provide support for running modified copies of this software.
The commands in this section require you to replace region
with a region where SSM is
available. To avoid cross-region data transfer costs for the download,
specify the region of your EC2 instance. For managed instances, there is no cross-region
data transfer cost, but we recommend that you specify the region closest to your data
center or computing environment.
Contents
Install the SSM Agent on EC2 Instances at Start-Up
You can install the SSM agent when you launch an instance for the first time by using EC2 User Data. On the Configure Instance Details page of the launch wizard, expand Advanced Details and then copy and paste one of the following scripts into the User data field. For example:

Amazon Linux, RHEL, and CentOS 64-bit
#!/bin/bash
cd /tmp
curl https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
yum install -y amazon-ssm-agent.rpmAmazon Linux, RHEL, and CentOS 32-bit
#!/bin/bash
cd /tmp
curl https://amazon-ssm-region.s3.amazonaws.com/latest/linux_386/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
yum install -y amazon-ssm-agent.rpmUbuntu Server 64-bit
#!/bin/bash
cd /tmp
curl https://amazon-ssm-region.s3.amazonaws.com/latest/debian_amd64/amazon-ssm-agent.deb -o amazon-ssm-agent.deb
dpkg -i amazon-ssm-agent.debUbuntu Server 32-bit
#!/bin/bash
cd /tmp
curl https://amazon-ssm-region.s3.amazonaws.com/latest/debian_386/amazon-ssm-agent.deb -o amazon-ssm-agent.deb
dpkg -i amazon-ssm-agent.debSave your changes, and complete the wizard. When the instance launches, the system copies the SSM agent to the instance and starts it. When the instance is online, you can configure it using Run Command. For more information, see Executing a Command Using Amazon EC2 Run Command.
Manually Install the SSM Agent on EC2 Instances
Use one of the following scripts to install the SSM agent on Amazon Linux,
Ubuntu, CentOS, or Red Hat Enterprise Linux. In these scripts, replace
region with a region where SSM is
available.
Install the SSM Agent on Amazon Linux
Connect to your Amazon Linux instance and perform the following steps to install the SSM agent. Perform these steps on each instance that will execute commands using Run Command.
To install the SSM agent on Amazon Linux
Create a temporary directory on the instance.
mkdir /tmp/ssmUse one of the following commands to download the SSM installer to the temporary directory. Replace
regionwith one of the AWS Regions where SSM is available. To avoid cross-region data transfer costs for the download, specify the region of your EC2 instance.64-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm32-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/linux_386/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpmRun the SSM installer.
sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpmRun the following command to determine if the SSM agent is running. The command should return "amazon-ssm-agent is running."
sudo status amazon-ssm-agentExecute the following commands if the previous command returns, "amazon-ssm-agent is stopped."
Start the service.
sudo start amazon-ssm-agentCheck the status of the agent.
sudo status amazon-ssm-agent
Install the SSM Agent on Ubuntu
Connect to your Ubuntu instance and perform the following steps to install the SSM agent. Perform these steps on each instance that will execute commands using Run Command.
To install the SSM agent on Ubuntu
Create a temporary directory on the instance.
mkdir /tmp/ssmUse one of the following commands to download the SSM installer to the temporary directory. Replace
regionwith one of the AWS Regions where SSM is available. To avoid cross-region data transfer costs for the download, specify the region of your EC2 instance.64-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/debian_amd64/amazon-ssm-agent.deb -o /tmp/ssm/amazon-ssm-agent.deb32-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/debian_386/amazon-ssm-agent.deb -o /tmp/ssm/amazon-ssm-agent.debRun the SSM installer.
sudo dpkg -i /tmp/ssm/amazon-ssm-agent.debRun the following command to determine if the SSM agent is running. The command should return "amazon-ssm-agent is running."
sudo status amazon-ssm-agentExecute the following commands if the previous command returned, "amazon-ssm-agent is stopped."
Start the service.
sudo start amazon-ssm-agentCheck the status of the agent.
sudo status amazon-ssm-agent
Install the SSM Agent on Red Hat Enterprise Linux
Connect to your Red Hat Enterprise Linux (RHEL) instance and perform the following steps to install the SSM agent. Perform these steps on each instance that will execute commands using Run Command.
To install the SSM agent on Red Hat Enterprise Linux
Create a temporary directory on the instance.
mkdir /tmp/ssmUse one of the following commands to download the SSM installer to the temporary directory. Replace
regionwith one of the AWS Regions where SSM is available. To avoid cross-region data transfer costs for the download, specify the region of your EC2 instance.64-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm32-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/linux_386/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpmRun the SSM installer.
sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpmRun one of the following commands to determine if the SSM agent is running. The command should return "amazon-ssm-agent is running."
RHEL 7.x
sudo systemctl status amazon-ssm-agentRHEL 6.x
sudo status amazon-ssm-agentExecute the following commands if the previous command returned "amazon-ssm-agent is stopped."
Start the service.
RHEL 7.x
sudo systemctl start amazon-ssm-agentRHEL 6.x
sudo start amazon-ssm-agentCheck the status of the agent.
RHEL 7.x
sudo systemctl status amazon-ssm-agentRHEL 6.x
sudo status amazon-ssm-agent
Install the SSM Agent on CentOS
Connect to your CentOS instance and perform the following steps to install the SSM agent. Perform these steps on each instance that will execute commands using Run Command.
To install the SSM agent on CentOS
Create a temporary directory on the instance.
mkdir /tmp/ssmUse one of the following commands to download the SSM installer to the temporary directory. Replace
regionwith one of the AWS Regions where SSM is available. To avoid cross-region data transfer costs for the download, specify the region of your EC2 instance.64-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm32-Bit
curl -O https://amazon-ssm-region.s3.amazonaws.com/latest/linux_386/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpmRun the SSM installer.
sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpmRun one of the following commands to determine if the SSM agent is running. The command should return "amazon-ssm-agent is running."
CentOS 7.x
sudo systemctl status amazon-ssm-agentCentOS 6.x
status amazon-ssm-agentExecute the following commands if the previous command returned "amazon-ssm-agent is stopped."
Start the service.
CentOS 7.x
sudo systemctl start amazon-ssm-agentCentOS 6.x
sudo start amazon-ssm-agentCheck the status of the agent.
CentOS 7.x
sudo systemctl status amazon-ssm-agentCentOS 6.x
sudo status amazon-ssm-agent
Install the SSM Agent on Managed Instances
Before you install the SSM agent on a managed instance (an on-premises server or VM that you want to configure using Run Command), verify that you completed the managed-instance activation process and that you created an IAM service role. For more information about managed instances and the activation process, see Setting Up Managed Instances. For more information about the IAM service role for managed instances, see Delegating Access to Amazon EC2 Run Command.
To install the SSM agent on a managed instance
Log on to the on-premises server or VM.
Copy and paste the following command block into the AWS CLI. Specify your activation code, activation ID, and the region where you want to download the SSM agent from. Note that
sudois not necessary if you are a root user.On Amazon Linux, RHEL 6.x, and CentOS 6.x
mkdir /tmp/ssm sudo curl https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpm sudo stop amazon-ssm-agent sudo amazon-ssm-agent -register -code "code" -id "id" -region "region" sudo start amazon-ssm-agentOn RHEL 7.x and CentOS 7.x
mkdir /tmp/ssm sudo curl https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpm sudo systemctl stop amazon-ssm-agent sudo amazon-ssm-agent -register -code "code" -id "id" -region "region" sudo systemctl start amazon-ssm-agentOn Ubuntu
mkdir /tmp/ssm sudo curl https://amazon-ssm-region.s3.amazonaws.com/latest/debian_amd64/amazon-ssm-agent.deb -o /tmp/ssm/amazon-ssm-agent.deb sudo dpkg -i /tmp/ssm/amazon-ssm-agent.deb sudo stop amazon-ssm-agent sudo amazon-ssm-agent -register -code "code" -id "id" -region "region" sudo start amazon-ssm-agentPress Enter.
The command downloads and installs the SSM agent onto the local server or VM. The command also registers the server or VM with the SSM service. The server or VM is now a managed instance.
For information about how to execute commands on managed instances using Run Command, see Executing a Command Using Amazon EC2 Run Command.
Configure the SSM Agent to Use a Proxy
You can configure the SSM agent to communicate through an HTTP proxy by adding
the http_proxy and no_proxy settings to
the SSM agent configuration file. This section includes procedures for
upstart and systemd environments.
To configure the SSM agent to use a proxy (Upstart)
Connect to the instance where you installed the SSM agent.
Open the amazon-ssm-agent.conf file in an editor such as VIM. By default, the file is located here:
/etc/init/amazon-ssm-agent.conf
Add the
http_proxysetting to the file in the following format:env http_proxy=http://hostname:portAdd the
no_proxysetting to the file in the following format. You must specify the IP address listed here. It is the instance metadata endpoint for SSM and without this IP address calls to SSM fail:env no_proxy=169.254.169.254Save your changes and close the editor.
Restart the SSM agent using the following command:
/sbin/restart amazon-ssm-agent
The following Upstart example includes the http_proxy and
no_proxy settings in the amazon-ssm-agent.conf file:
description "Amazon SSM Agent"
author "Amazon.com"
start on (runlevel [345] and started network)
stop on (runlevel [!345] or stopping network)
respawn
env http_proxy=http://i-1234567890abcdef0:443
env no_proxy=169.254.169.254
chdir /usr/bin/
exec ./amazon-ssm-agentTo configure the SSM agent to use a proxy (systemd)
Connect to the instance where you installed the SSM agent.
Open the amazon-ssm-agent.service file in an editor such as VIM. By default, the file is located here:
/etc/systemd/system/amazon-ssm-agent.service
Add the
http_proxysetting to the file in the following format:Environment="HTTP_PROXY=http://hostname:port"Add the
no_proxysetting to the file in the following format. You must specify the IP address listed here. It is the instance metadata endpoint for SSM and without this IP address calls to SSM fail:Environment="no_proxy=169.254.169.254"Save your changes and close the editor.
Restart the SSM agent using the following commands:
systemctl stop amazon-ssm-agent systemctl daemon-reload
The following systemd example includes the http_proxy and
no_proxy settings in the amazon-ssm-agent.service
file:
Type=simple
Environment="HTTP_PROXY=http://i-1234567890abcdef0:443"
Environment="no_proxy=169.254.169.254"
WorkingDirectory=/opt/amazon/ssm/
ExecStart=/usr/bin/amazon-ssm-agent
KillMode=process
Restart=on-failure
RestartSec=15minUninstall the SSM Agent
Use the following commands to uninstall the SSM agent.
To uninstall the SSM agent on Amazon Linux, RHEL, or Cent OS
sudo yum erase amazon-ssm-agent –yTo uninstall the SSM agent on Ubuntu
sudo dpkg -r amazon-ssm-agent


