{"id":1628,"date":"2025-07-20T10:15:11","date_gmt":"2025-07-20T10:15:11","guid":{"rendered":"https:\/\/192.168.1.3\/wordpress\/?p=1628"},"modified":"2026-04-21T14:08:21","modified_gmt":"2026-04-21T06:08:21","slug":"hybrid-activation-manage-non-ec2-machines-from-aws-system-manager","status":"publish","type":"post","link":"https:\/\/mylinuxsite.com\/wordpress\/?p=1628","title":{"rendered":"Hybrid Activation &#8211; Manage Non-EC2 machines from AWS System Manager"},"content":{"rendered":"\n<p>In this article, we will demonstrate how we can manage Non-EC2 on-premise machines from the AWS System Manager using Hybrid Activation.<\/p>\n\n\n\n<p>For this demonstration, our on-premises machine will be a Linux VM running on Oracle VirtualBox.  The flavour of Linux that we will use <strong>is CentOS 7<\/strong>.  But you may use any other Linux flavour. The reason why I am using CentOS 7 is that my Oracle VirtualBox is old and cannot be updated.<\/p>\n\n\n\n<p>In summary, the procedures we need to take are as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install the SSM Agent on our Linux machine.<\/li>\n\n\n\n<li>Create an IAM Service Role that our machine or the agents in our machine will use.<\/li>\n\n\n\n<li>Create a Hybrid Activation and register our machine with the AWS System Manager.<\/li>\n\n\n\n<li>Install and configure the CloudWatch agent on our Linux machine using the System Manager.<\/li>\n\n\n\n<li>Install AWS CLI on our Linux machine using the System Manager.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. Install the SSM Agent<\/strong><\/h4>\n\n\n\n<p>There are several ways to install the SSM agent on your on-premise machine. One option, ideal for managing a large number of machines, is to utilise automation tools such as Ansible, Puppet, or Chef.  But for this demonstration, we will log in to our machine and enter the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum install -y https:\/\/s3.amazonaws.com\/ec2-downloads-windows\/SSMAgent\/latest\/linux_amd64\/amazon-ssm-agent.rpm<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-18-27-36.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"372\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-18-27-36-1024x372.png\" alt=\"\" class=\"wp-image-1668\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-18-27-36-1024x372.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-18-27-36-300x109.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-18-27-36-768x279.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-18-27-36.png 1336w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Refer to <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.aws.amazon.com\/systems-manager\/latest\/userguide\/manually-install-ssm-agent-linux.html\" data-type=\"URL\" data-id=\"https:\/\/docs.aws.amazon.com\/systems-manager\/latest\/userguide\/manually-install-ssm-agent-linux.html\" target=\"_blank\">this<\/a> link if you are using a different Linux flavour.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Create an IAM Service Role<\/strong><\/h4>\n\n\n\n<p>The IAM service role that we will create will be used by both the SSM agent and the CloudWatch agent, which will be installed later.  When we run the registration command,<span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">&nbsp;the SSM agent cr<\/span>eates a&nbsp;<em>credentials<\/em>&nbsp;file with a <em>default<\/em> profile in the&nbsp;root&nbsp;account (or the account where the registration command is run), containing the ACCESS_ID and ACCESS_KEY derived from the IAM service role. <\/p>\n\n\n\n<p>Create a local text file with the following trust policy:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &lt;&lt;EOF &gt; MyOnPremServiceRole-Trust.json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": &#91;\n        {\n            \"Effect\": \"Allow\",\n            \"Principal\": {\n                \"Service\": \"ssm.amazonaws.com\"\n            },\n            \"Action\": \"sts:AssumeRole\"\n        }\n    ]\n}\nEOF<\/code><\/pre>\n\n\n\n<p>Create a role with the above trust policy:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws iam create-role \\\n    --role-name MyOnPremServiceRole \\\n    --assume-role-policy-document file:\/\/MyOnPremServiceRole-Trust.json<\/code><\/pre>\n\n\n\n<p>Attached the policies (1) <a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/us-east-1.console.aws.amazon.com\/iam\/home?region=us-east-1#\/policies\/details\/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FAmazonSSMManagedInstanceCore\">AmazonSSMManagedInstanceCore<\/a> and (2) <a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/us-east-1.console.aws.amazon.com\/iam\/home?region=us-east-1#\/policies\/details\/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FCloudWatchAgentServerPolicy\">CloudWatchAgentServerPolicy<\/a> to the role.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws iam attach-role-policy \\\n    --role-name MyOnPremServiceRole \\\n    --policy-arn arn:aws:iam::aws:policy\/AmazonSSMManagedInstanceCore  \n\naws iam attach-role-policy \\\n    --role-name MyOnPremServiceRole \\\n    --policy-arn arn:aws:iam::aws:policy\/CloudWatchAgentServerPolicy<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-04-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"426\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-04-17-1024x426.png\" alt=\"\" class=\"wp-image-1671\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-04-17-1024x426.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-04-17-300x125.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-04-17-768x320.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-04-17.png 1429w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3. Create a Hybrid Activation<\/strong><\/h4>\n\n\n\n<p>Create a Hybrid activation using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws ssm create-activation \\\n  --default-instance-name MyOnPremServers \\\n  --description \"Activation for my on-prem servers\" \\\n  --iam-role MyOnPremServiceRole \\\n  --expiration-date \"2025-07-30T00:00:00\" \\\n  --registration-limit 2 \\\n  --region us-east-1 \\\n  --tags \"Key=ServerOS,Value=CentOS7\"<\/code><\/pre>\n\n\n\n<p>The command should output the <strong>ActivationId<\/strong> and the <strong>ActivationCode<\/strong>. Use these values to register your machine.<\/p>\n\n\n\n<p> Log in to your server and run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>amazon-ssm-agent -register -code \"&lt;ActivationCode&gt;\" -id \"&lt;ActivationId&gt;\" -region \"us-east-1\"<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-27-02-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"143\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-27-02-1-1024x143.png\" alt=\"\" class=\"wp-image-1682\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-27-02-1-1024x143.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-27-02-1-300x42.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-27-02-1-768x107.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-27-02-1.png 1279w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Verify the Hybrid activation and registration from the console. First, go to the <em>Hybrid Activations<\/em> panel. You should see an entry similar to the image below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"169\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39-1024x169.png\" alt=\"\" class=\"wp-image-1666\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39-1024x169.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39-300x50.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39-768x127.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39-1536x254.png 1536w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-22-39.png 1559w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Then go to the <em>Fleet Manager<\/em> panel. You should see your instance <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">listed there with a&nbsp;<em>Ping status<\/em>&nbsp;set to&nbsp;<em>&#8216;Online&#8217;<\/em><\/span>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"214\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37-1024x214.png\" alt=\"\" class=\"wp-image-1664\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37-1024x214.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37-300x63.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37-768x160.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37-1536x321.png 1536w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-18-21-29-37.png 1805w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>4. Install and configure the CloudWatch agent.<\/strong><\/h4>\n\n\n\n<p>To test and demonstrate that the System Manager can now manage our machine, we will install and configure the CloudWatch agent using the System Manager <em>Run Command<\/em>.<\/p>\n\n\n\n<p><em>First<\/em>, we need to install the CloudWatch agent package using the document <strong>AWS-ConfigureAWSPackage<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws ssm send-command \\\n    --document-name \"AWS-ConfigureAWSPackage\" \\\n    --parameters action=\"Install\",installationType=\"Uninstall and reinstall\",name=\"AmazonCloudWatchAgent\",version=\"latest\" \\\n    --region us-east-1 \\ \n    --targets Key=tag:ServerOS,Values=CentOS7<\/code><\/pre>\n\n\n\n<p>Verify from the <em>Run Command <\/em>panel that the run is successful. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-20-46-47.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"556\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-20-46-47-1024x556.png\" alt=\"\" class=\"wp-image-1675\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-20-46-47-1024x556.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-20-46-47-300x163.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-20-46-47-768x417.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-20-46-47.png 1526w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>You can also verify this from the machine itself to confirm that the package is installed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-11-23-55.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"233\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-11-23-55-1024x233.png\" alt=\"\" class=\"wp-image-1662\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-11-23-55-1024x233.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-11-23-55-300x68.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-11-23-55-768x175.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-11-23-55.png 1348w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><em>Next<\/em>, we need to instruct the CloudWatch agent to use the <em>\/root\/.aws\/credentials<\/em> as our credential file.  We <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">accomplish this by uncommenting the lines in <strong>\/opt\/aws\/amazon-cloudwatch-agent\/etc\/common-config.toml,<\/strong>&nbsp;specifically the <em>[credentials] <\/em>section and the <em>shared_credential_profile<\/em> parameter, <\/span>and&nbsp;assigning<span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\"> a value of &#8216;<em>default<\/em>&#8216;.<\/span><\/p>\n\n\n\n<p>We will use the <strong>AWS-RunShellScript<\/strong> run document for this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws ssm send-command \\\n    --document-name \"AWS-RunShellScript\" \\\n    --parameters '{\"workingDirectory\":&#91;\"\/opt\/aws\/amazon-cloudwatch-agent\/etc\"],\"executionTimeout\":&#91;\"3600\"],\"commands\":&#91;\"if ! test -f common-config.toml.bak; then cp common-config.toml common-config.toml.bak; fi\",\"sed -e '\"'\"'s\/\\\\# \\\\&#91;credentials\\\\]\/\\\\&#91;credentials\\\\]\/'\"'\"' -e '\"'\"'s\/\\\\#    shared_credential_profile = \\\\\\\"{profile_name}\\\\\\\"\/ shared_credential_profile = \\\\\\\"default\\\\\\\"\/'\"'\"' common-config.toml.bak &gt; common-config.toml\"]}' \\\n    --timeout-seconds 600 \\\n    --region us-east-1 \\ \n    --targets Key=tag:ServerOS,Values=CentOS7<\/code><\/pre>\n\n\n\n<p>Verify the result of the run by taking the <em>diff <\/em>between the original and the modified file<strong>.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-16-25-56.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"302\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-16-25-56-1024x302.png\" alt=\"\" class=\"wp-image-1659\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-16-25-56-1024x302.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-16-25-56-300x89.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-16-25-56-768x227.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-16-25-56.png 1348w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><em>Next<\/em>, we need to add a default region to our <em><strong>\/root\/.aws\/credentials<\/strong><\/em>. This is necessary because the Run Command document we will execute later to configure and start the CloudWatch agent will read the tokens and region from this file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws ssm send-command \\\n    --document-name \"AWS-RunShellScript\" \\\n    --parameters '{\"workingDirectory\":&#91;\"\/root\/.aws\"],\"executionTimeout\":&#91;\"3600\"],\"commands\":&#91;\"if ! test -f credentials.bak; then cp credentials credentials.bak; fi\",\"sed '\"'\"'\/\\\\&#91;default\\\\]\/a\\\\region = us-east-1'\"'\"' credentials.bak &gt; credentials\"]}' \\\n    --timeout-seconds 600 \\\n    --region us-east-1 \\ \n    --targets Key=tag:ServerOS,Values=CentOS7<\/code><\/pre>\n\n\n\n<p>Verify the result of the run by taking the <em>diff <\/em>between the original and the modified file<strong>.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-17-46-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"265\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-17-46-11-1024x265.png\" alt=\"\" class=\"wp-image-1658\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-17-46-11-1024x265.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-17-46-11-300x78.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-17-46-11-768x198.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-17-46-11.png 1343w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Next, we will create the CloudWatch agent configuration file and store it in the SSM Parameter Store. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &lt;&lt;EOF &gt; OnPremCWAgent-config.json\n{\n    \"agent\": {\n        \"metrics_collection_interval\": 60,\n        \"run_as_user\": \"root\",\n        \"region\": \"us-east-1\"\n    },\n    \"logs\": {\n        \"logs_collected\": {\n            \"files\": {\n                \"collect_list\": &#91;\n                    {\n                        \"file_path\": \"\/var\/log\/secure\",\n                        \"log_group_class\": \"STANDARD\",\n                        \"log_group_name\": \"MyOnPrem\",\n                        \"log_stream_name\": \"{local_hostname}\",\n                        \"retention_in_days\": -1\n                    }\n                ]\n            }\n        }\n    },\n\t\"metrics\": {\n                \"namespace\": \"MyOnPremNamespace\",\n\t\t\"metrics_collected\": {\n\t\t\t\"cpu\": {\n\t\t\t\t\"measurement\": &#91;\n\t\t\t\t\t\"cpu_usage_idle\"\n\t\t\t\t],\n\t\t\t\t\"metrics_collection_interval\": 60,\n\t\t\t\t\"resources\": &#91;\n\t\t\t\t\t\"*\"\n\t\t\t\t],\n\t\t\t\t\"totalcpu\": true\n\t\t\t},\n\t\t\t\"disk\": {\n\t\t\t\t\"measurement\": &#91;\n\t\t\t\t\t\"used_percent\"\n\t\t\t\t],\n\t\t\t\t\"metrics_collection_interval\": 60,\n\t\t\t\t\"resources\": &#91;\n\t\t\t\t\t\"*\"\n\t\t\t\t]\n\t\t\t},\n\t\t\t\"diskio\": {\n\t\t\t\t\"measurement\": &#91;\n\t\t\t\t\t\"write_bytes\",\n\t\t\t\t\t\"read_bytes\",\n\t\t\t\t\t\"writes\",\n\t\t\t\t\t\"reads\"\n\t\t\t\t],\n\t\t\t\t\"metrics_collection_interval\": 60,\n\t\t\t\t\"resources\": &#91;\n\t\t\t\t\t\"*\"\n\t\t\t\t]\n\t\t\t},\n\t\t\t\"mem\": {\n\t\t\t\t\"measurement\": &#91;\n\t\t\t\t\t\"mem_used_percent\"\n\t\t\t\t],\n\t\t\t\t\"metrics_collection_interval\": 60\n\t\t\t},\n\t\t\t\"net\": {\n\t\t\t\t\"measurement\": &#91;\n\t\t\t\t\t\"bytes_sent\",\n\t\t\t\t\t\"bytes_recv\",\n\t\t\t\t\t\"packets_sent\",\n\t\t\t\t\t\"packets_recv\"\n\t\t\t\t],\n\t\t\t\t\"metrics_collection_interval\": 60,\n\t\t\t\t\"resources\": &#91;\n\t\t\t\t\t\"*\"\n\t\t\t\t]\n\t\t\t},\n\t\t\t\"swap\": {\n\t\t\t\t\"measurement\": &#91;\n\t\t\t\t\t\"swap_used_percent\"\n\t\t\t\t],\n\t\t\t\t\"metrics_collection_interval\": 60\n\t\t\t}\n\t\t}\n\t}\n}\nEOF\n\naws ssm put-parameter \\\n    --region us-east-1 \\\n    --name OnPremCWAgent-config \\\n    --type String \\\n    --value file:\/\/OnPremCWAgent-config.json<\/code><\/pre>\n\n\n\n<p>Please note that in our configuration file, we will collect the log fil<em>e \/var\/log\/secure<\/em> and store it in the log group <em>MyOnPrem<\/em>. We will also collect metrics, including disk usage, CPU usage, and memory usage and place them under <em>MyOnPremNamespace<\/em> namespace.<\/p>\n\n\n\n<p>Finally, start the CloudWatch agent with the configuration file we uploaded to the SSM Parameter store. We will use the <strong>AmazonCloudWatch-ManageAgent <\/strong>document for this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws ssm send-command \\\n    --document-name \"AmazonCloudWatch-ManageAgent\" \\\n    --parameters '{\"action\":&#91;\"configure\"],\"mode\":&#91;\"onPremise\"],\"optionalConfigurationSource\":&#91;\"ssm\"],\"optionalConfigurationLocation\":&#91;\"OnPremCWAgent-config\"],\"optionalRestart\":&#91;\"yes\"]}' \\\n    --timeout-seconds 600 \\\n    --region us-east-1 \\\n    --targets Key=tag:ServerOS,Values=CentOS7<\/code><\/pre>\n\n\n\n<p>Verify the result of the run by checking if the <strong>amazon-cloudwatch-agent.service <\/strong>is running on the machine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-20-09-15-26.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"282\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-20-09-15-26-1024x282.png\" alt=\"\" class=\"wp-image-1683\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-20-09-15-26-1024x282.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-20-09-15-26-300x83.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-20-09-15-26-768x211.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-20-09-15-26.png 1345w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Logs under the log group <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\"><em>&#8216;MyOnPrem&#8217;&nbsp;<\/em>and metrics under the namespace&nbsp;<em>&#8216;MyOnPre<\/em><\/span><em>mNamespace&#8217;<\/em> should also be created.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"432\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m-1024x432.png\" alt=\"\" class=\"wp-image-1689\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m-1024x432.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m-300x127.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m-768x324.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m-1536x648.png 1536w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-37-04-m.png 1649w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Log Group<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"222\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46-1024x222.png\" alt=\"\" class=\"wp-image-1656\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46-1024x222.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46-300x65.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46-768x166.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46-1536x332.png 1536w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-39-46.png 1641w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Metrics<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>5. Install AWS CLI on the Linux machine.<\/strong><\/h4>\n\n\n\n<p>For completion, we will install the AWS CLI on our Linux machine using the <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\"><strong>AWS RunShellScript <\/strong>document<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws ssm send-command \\\n    --document-name \"AWS-RunShellScript\" \\\n    --parameters '{\"workingDirectory\":&#91;\"\"],\"executionTimeout\":&#91;\"3600\"],\"commands\":&#91;\"curl \\\"https:\/\/awscli.amazonaws.com\/awscli-exe-linux-x86_64.zip\\\" -o \\\"awscliv2.zip\\\"\",\"unzip awscliv2.zip\",\".\/aws\/install\",\"\",\"\"]}' \\\n    --timeout-seconds 600 \\\n    --region us-east-1 \\\n    --targets Key=tag:ServerOS,Values=CentOS7<\/code><\/pre>\n\n\n\n<p>Verify the result of the run by checking if the AWS CLI is installed on the machine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-50-59.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"142\" src=\"http:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-50-59-1024x142.png\" alt=\"\" class=\"wp-image-1655\" srcset=\"https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-50-59-1024x142.png 1024w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-50-59-300x42.png 300w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-50-59-768x106.png 768w, https:\/\/mylinuxsite.com\/wordpress\/wp-content\/uploads\/2025\/07\/Screenshot-from-2025-07-19-19-50-59.png 1344w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will demonstrate how we can manage Non-EC2 on-premise machines from the AWS System Manager using Hybrid Activation. For this demonstration, our on-premises machine will be a Linux VM running on Oracle VirtualBox. The flavour of Linux that we will use is CentOS 7. But you may use any other Linux flavour. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1628","post","type-post","status-publish","format-standard","hentry","category-articles"],"_links":{"self":[{"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1628"}],"version-history":[{"count":37,"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1628\/revisions"}],"predecessor-version":[{"id":1985,"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1628\/revisions\/1985"}],"wp:attachment":[{"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mylinuxsite.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}