This guide describes how to enable the Cmd agent on AWS SSM-managed servers.
This example uses an Amazon Linux 2 instance running SSM on AWS. These instructions also apply to most Debian variants using systemd.
Prerequisites
First, install the Cmd agent to your target server images.
Then, configure the SSM agent as follows:
SSM configuration script
This script changes the /etc/systemd/system/amazon-ssm-agent.service
file*:
Under the [Unit] directive, it adds the line:
After=cmd.service
Under the [Service] directive, it adds the line:
Environment=LD_PRELOAD=libinjector.so
#!/bin/bash
cp /etc/systemd/system/amazon-ssm-agent.service /etc/systemd/system/amazon-ssm-agent.service.orig
sed -i 's/\[Unit\]/\[Unit\]\nAfter=cmd.service/g' /etc/systemd/system/amazon-ssm-agent.service
sed -i 's/\[Service\]/\[Service\]\nEnvironment=LD_PRELOAD=libinjector.so/g' /etc/systemd/system/amazon-ssm-agent.service
systemctl daemon-reload
systemctl restart amazon-ssm-agent.service
Within a couple minutes, your servers will appear at app.cmd.com/settings/servers.
* Note: If this file doesn't exist yet, you can make a copy of the default version with e.g.: cp /usr/lib/systemd/system/amazon-ssm-agent.service /etc/systemd/system/amazon-ssm-agent.service