- Lab
- A Cloud Guru
Installing and Configuring SSM Agent on Linux
The Systems Manager Agent (SSM Agent) is at the heart of all the automation, management, and other tasks possible via Systems Manager. It must be installed on any machine managed by SSM. In this hands-on lab, we will manually install and configure SSM Agent on a Linux OS on an EC2 instance. We will then assign an appropriate SSM IAM role to our EC2 instance to be configured with Systems Manager. This lab assumes some knowledge of Linux — specifically, RHEL/CentOS package management and some general Linux skills.
Path Info
Table of Contents
-
Challenge
Log in to the EC2 Instance via SSH
Log in to the EC2 instance provisioned for you by the lab:
ssh cloud_user<PUBLIC_IP_OF_EC2_INSTANCE>
-
Challenge
Install the SSM Agent Using YUM
The EC2 instance in our case is a CentOS 7 system, so we will install the appropriate SSM Agent RPM binary on it with the following command. (Keep the
cloud_user
password handy.)wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm sudo yum -y localinstall amazon-ssm-agent.rpm
Even though the download URLs has
ec2-downloads-windows
, these are the correct URLs for Linux/CentOS. -
Challenge
Log in to the AWS Console and Create IAM SSM Role for EC2
- Log in to the AWS console using the credentials provided on the lab page.
- Head to IAM > Roles.
- Click Create role.
- Select EC2 as the service that will use this role.
- Click Next: Permissions.
- In the search bar, type "AmazonEC2RoleforSSM", select this role, and click Next: Tags.
- Leave tags as default, and click Next: Review.
- Assign your role a name such as "MyEC2SSMRole".
- Click Create role.
-
Challenge
Attach IAM Role to EC2 Instance
- Head to the EC2 console and under Running Instances, look for the instance tagged (named) SSMInstallInstance.
- This instance, which was provisioned by the lab, is the same one you logged into and installed SMS Agent on using YUM.
- Select this instance.
- Click the Actions dropdown.
- Scroll to Instance Settings.
- Click Attach/Replace IAM Role.
- From the dropdown, select your IAM role and then click Apply.
- Head to the EC2 console and under Running Instances, look for the instance tagged (named) SSMInstallInstance.
-
Challenge
Log Back in to Command Line of EC2 Instance
Head back to the CLI of your EC2 instance that you installed SSM Agent on earlier. We will enable and start the SSM Agent so it can survive reboots and communicate with Systems Manager.
-
Enable SSM Agent:
sudo systemctl enable amazon-ssm-agent
-
Start SSM Agent:
sudo systemctl start amazon-ssm-agent
-
To confirm the SSM Agent has started and is running successfully, check its status:
sudo systemctl status amazon-ssm-agent
The output should show an
active/running
status.
-
-
Challenge
Check Logs for SSM Agent and Enable Debug Logging for It
Look at the SSM Agent log file, which houses all communication logs and actions that SSM Agent is performing on the instance:
/var/log/amazon/ssm/amazon-ssm-agent.log
The verbosity of SSM Agent logging can be increased by copying over and modifying a configuration file (
/etc/amazon/ssm/seelog.xml.template
) that comes by default with the SSM Agent install. To do so, carry out the following steps:-
Copy the example template to its original file name so it can be detected by SSM Agent:
sudo cp /etc/amazon/ssm/seelog.xml.template /etc/amazon/ssm/seelog.xml
-
Edit the file you just copied:
sudo vim /etc/amazon/ssm/seelog.xml
-
Look for this line in the file:
<seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="info">
Change
minlevel="info"
tominlevel="debug"
. Save and quit the file. -
Restart SSM Agent:
sudo systemctl restart amazon-ssm-agent
-
Tail the SSM Agent's log file to observe the newly enabled verbosity (debug):
sudo tail -f /var/log/amazon/ssm/amazon-ssm-agent.log
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.