{"id":1793,"date":"2025-01-09T14:00:39","date_gmt":"2025-01-09T06:00:39","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=1793"},"modified":"2025-01-09T14:00:39","modified_gmt":"2025-01-09T06:00:39","slug":"what-are-aws-ssm-and-ssm-agent-how-they-work","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=1793","title":{"rendered":"What are AWS SSM and SSM Agent, how they work?"},"content":{"rendered":"<h3><strong>AWS SSM \u548c SSM Agent \u662f\u4ec0\u4e48\uff1f<\/strong><\/h3>\n<h4><strong>AWS Systems Manager (SSM)<\/strong><\/h4>\n<p>AWS Systems Manager \u662f\u4e00\u9879\u670d\u52a1\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u754c\u9762\uff0c\u7528\u4e8e\u7ba1\u7406 AWS \u8d44\u6e90\uff08\u5982 EC2 \u5b9e\u4f8b\u3001RDS \u6570\u636e\u5e93\uff09\u548c\u672c\u5730\u670d\u52a1\u5668\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7ba1\u7406\u5458\u81ea\u52a8\u5316\u5e38\u89c1\u7ba1\u7406\u4efb\u52a1\uff0c\u4f8b\u5982\u8f6f\u4ef6\u66f4\u65b0\u3001\u914d\u7f6e\u7ba1\u7406\u548c\u7cfb\u7edf\u76d1\u63a7\u3002<\/p>\n<h4><strong>SSM Agent<\/strong><\/h4>\n<p>SSM Agent \u662f\u5b89\u88c5\u5728 EC2 \u5b9e\u4f8b\u6216\u672c\u5730\u670d\u52a1\u5668\u4e0a\u7684\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u5ba2\u6237\u7aef\u8f6f\u4ef6\uff0c\u7528\u4e8e\u63a5\u6536\u6765\u81ea AWS Systems Manager \u7684\u547d\u4ee4\u5e76\u6267\u884c\u5b83\u4eec\uff0c\u4f8b\u5982\u8fd0\u884c\u811a\u672c\u3001\u5b89\u88c5\u66f4\u65b0\u3001\u6536\u96c6\u65e5\u5fd7\u7b49\u3002<\/p>\n<hr \/>\n<h3><strong>AWS SSM \u7684\u7528\u9014<\/strong><\/h3>\n<ol>\n<li>\n<p><strong>\u8fdc\u7a0b\u7ba1\u7406<\/strong>:<\/p>\n<ul>\n<li>\u5141\u8bb8\u901a\u8fc7 AWS \u63a7\u5236\u53f0\u6216 CLI \u8fdc\u7a0b\u7ba1\u7406 EC2 \u5b9e\u4f8b\u6216\u672c\u5730\u670d\u52a1\u5668\uff0c\u800c\u65e0\u9700\u624b\u52a8\u767b\u5f55\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u81ea\u52a8\u5316\u4efb\u52a1<\/strong>:<\/p>\n<ul>\n<li>\u81ea\u52a8\u5316\u4efb\u52a1\uff0c\u5982\u8865\u4e01\u7ba1\u7406\u3001\u8f6f\u4ef6\u5206\u53d1\u548c\u5b9a\u671f\u5907\u4efd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u547d\u4ee4<\/strong>:<\/p>\n<ul>\n<li>\u5728\u591a\u4e2a\u5b9e\u4f8b\u4e0a\u540c\u65f6\u6267\u884c\u811a\u672c\u6216\u547d\u4ee4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u7ba1\u7406<\/strong>:<\/p>\n<ul>\n<li>\u4f7f\u7528\u53c2\u6570\u5b58\u50a8\u7ba1\u7406\u914d\u7f6e\u6570\u636e\u548c\u5bc6\u94a5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5408\u89c4\u6027\u548c\u5ba1\u8ba1<\/strong>:<\/p>\n<ul>\n<li>\u5b9e\u73b0\u914d\u7f6e\u5408\u89c4\u6027\u68c0\u67e5\u548c\u5ba1\u8ba1\uff0c\u786e\u4fdd\u7cfb\u7edf\u914d\u7f6e\u7b26\u5408\u5b89\u5168\u6807\u51c6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>SSM Agent \u7684\u7528\u9014<\/strong><\/h3>\n<ol>\n<li>\n<p><strong>\u63a5\u6536\u548c\u6267\u884c\u547d\u4ee4<\/strong>:<\/p>\n<ul>\n<li>\u4ece Systems Manager \u670d\u52a1\u63a5\u6536\u547d\u4ee4\uff0c\u5982\u201c\u8fd0\u884c\u811a\u672c\u201d\u6216\u201c\u5b89\u88c5\u8f6f\u4ef6\u201d\uff0c\u5e76\u5728\u672c\u5730\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4e0e Systems Manager \u96c6\u6210<\/strong>:<\/p>\n<ul>\n<li>\u901a\u8fc7 Agent\uff0cSSM \u670d\u52a1\u53ef\u4ee5\u4e0e EC2 \u5b9e\u4f8b\u6216\u672c\u5730\u670d\u52a1\u5668\u65e0\u7f1d\u4ea4\u4e92\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u53c2\u6570\u5b58\u50a8<\/strong>:<\/p>\n<ul>\n<li>\u652f\u6301\u4ece AWS SSM \u53c2\u6570\u5b58\u50a8\u5b89\u5168\u83b7\u53d6\u914d\u7f6e\u503c\u548c\u5bc6\u94a5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u65e5\u5fd7\u6536\u96c6<\/strong>:<\/p>\n<ul>\n<li>\u5c06\u5b9e\u4f8b\u65e5\u5fd7\u63a8\u9001\u5230 AWS CloudWatch \u6216 S3 \u4ee5\u4f9b\u5206\u6790\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>AWS SSM \u548c SSM Agent \u7684\u5de5\u4f5c\u539f\u7406<\/strong><\/h3>\n<h4><strong>1. \u5b89\u88c5\u548c\u914d\u7f6e SSM Agent<\/strong><\/h4>\n<ul>\n<li>SSM Agent \u9ed8\u8ba4\u9884\u5b89\u88c5\u5728 Amazon Linux\u3001Ubuntu\u3001Windows Server \u548c\u90e8\u5206 AWS Marketplace AMI \u4e2d\u3002<\/li>\n<li>\u5bf9\u4e8e\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff0c\u53ef\u4ee5\u624b\u52a8\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<h4><strong>2. \u5b9e\u4f8b\u4e0e SSM \u670d\u52a1\u7684\u901a\u4fe1<\/strong><\/h4>\n<ul>\n<li>\n<p><strong>\u5b9e\u4f8b\u914d\u7f6e\u6587\u4ef6\uff08IAM Role\uff09<\/strong>:<\/p>\n<ul>\n<li>EC2 \u5b9e\u4f8b\u9700\u8981\u4e00\u4e2a IAM Role\uff0c\u5176\u4e2d\u5305\u542b <strong><code>AmazonSSMManagedInstanceCore<\/code><\/strong> \u6743\u9650\uff0c\u5141\u8bb8 SSM Agent \u5411 AWS Systems Manager \u670d\u52a1\u6ce8\u518c\u5e76\u53d1\u9001\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u901a\u4fe1\u65b9\u5f0f<\/strong>:<\/p>\n<ul>\n<li>SSM Agent \u4f7f\u7528 HTTPS \u901a\u4fe1\uff0c\u786e\u4fdd\u5b89\u5168\u4f20\u8f93\u3002<\/li>\n<li>Agent \u4f1a\u5b9a\u671f\u8f6e\u8be2 AWS Systems Manager \u670d\u52a1\uff0c\u68c0\u67e5\u662f\u5426\u6709\u547d\u4ee4\u9700\u8981\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4><strong>3. \u547d\u4ee4\u6267\u884c\u6d41\u7a0b<\/strong><\/h4>\n<ul>\n<li>\u7ba1\u7406\u5458\u901a\u8fc7 AWS \u63a7\u5236\u53f0\u3001CLI \u6216 SDK \u53d1\u51fa\u547d\u4ee4\u3002<\/li>\n<li>SSM \u670d\u52a1\u5c06\u547d\u4ee4\u53d1\u9001\u5230\u76ee\u6807\u5b9e\u4f8b\u7684 SSM Agent\u3002<\/li>\n<li>SSM Agent \u6267\u884c\u547d\u4ee4\u5e76\u8fd4\u56de\u7ed3\u679c\u7ed9 SSM \u670d\u52a1\u3002<\/li>\n<li>\u7ba1\u7406\u5458\u53ef\u901a\u8fc7 SSM \u63a7\u5236\u53f0\u67e5\u770b\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<h4><strong>4. \u53c2\u6570\u5b58\u50a8\u7684\u4f7f\u7528<\/strong><\/h4>\n<ul>\n<li>\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u5728 AWS SSM \u53c2\u6570\u5b58\u50a8\u4e2d\u5b58\u50a8\u914d\u7f6e\u6570\u636e\u6216\u654f\u611f\u4fe1\u606f\uff08\u5982\u6570\u636e\u5e93\u5bc6\u7801\uff09\u3002<\/li>\n<li>SSM Agent \u53ef\u4ee5\u901a\u8fc7\u5b89\u5168 API \u83b7\u53d6\u8fd9\u4e9b\u53c2\u6570\uff0c\u5e76\u5728\u672c\u5730\u5e94\u7528\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>\u793a\u4f8b\uff1aAWS SSM \u6267\u884c\u547d\u4ee4<\/strong><\/h3>\n<h4>\u573a\u666f\uff1a\u5728\u591a\u53f0 EC2 \u5b9e\u4f8b\u4e0a\u5b89\u88c5 NGINX<\/h4>\n<ol>\n<li>\n<p><strong>Step 1: \u8bbe\u7f6e IAM Role<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5b9e\u4f8b\u9644\u52a0\u7684 IAM Role \u542b\u6709 <code>AmazonSSMManagedInstanceCore<\/code> \u6743\u9650\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Step 2: \u53d1\u51fa\u547d\u4ee4<\/strong><br \/>\n\u4f7f\u7528 AWS CLI \u53d1\u51fa\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">aws ssm send-command \\\n   --document-name \"AWS-RunShellScript\" \\\n   --targets \"Key=tag:Environment,Values=Production\" \\\n   --parameters 'commands=[\"sudo yum install -y nginx\", \"sudo systemctl start nginx\"]' \\\n   --region us-east-1<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>Step 3: \u68c0\u67e5\u72b6\u6001<\/strong><br \/>\n\u5728 Systems Manager \u63a7\u5236\u53f0\u67e5\u770b\u547d\u4ee4\u72b6\u6001\uff0c\u786e\u4fdd\u6240\u6709\u5b9e\u4f8b\u90fd\u6210\u529f\u6267\u884c\u4e86\u547d\u4ee4\u3002<\/p>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>\u793a\u4f8b\uff1aSSM \u53c2\u6570\u5b58\u50a8<\/strong><\/h3>\n<h4>\u573a\u666f\uff1a\u5b89\u5168\u5b58\u50a8\u6570\u636e\u5e93\u5bc6\u7801<\/h4>\n<ol>\n<li>\n<p><strong>Step 1: \u5b58\u50a8\u5bc6\u7801<\/strong><br \/>\n\u4f7f\u7528 CLI \u5c06\u5bc6\u7801\u5b58\u50a8\u5230 SSM \u53c2\u6570\u5b58\u50a8\uff1a<\/p>\n<pre><code class=\"language-bash\">aws ssm put-parameter \\\n   --name \"DBPassword\" \\\n   --value \"MySecurePassword123\" \\\n   --type \"SecureString\"<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>Step 2: \u4ece\u5b9e\u4f8b\u8bbf\u95ee\u5bc6\u7801<\/strong><br \/>\n\u5728\u76ee\u6807\u5b9e\u4f8b\u4e0a\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u83b7\u53d6\u5bc6\u7801\uff1a<\/p>\n<pre><code class=\"language-bash\">aws ssm get-parameter --name \"DBPassword\" --with-decryption<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>AWS SSM \u548c SSM Agent \u7684\u4f18\u52bf<\/strong><\/h3>\n<ol>\n<li>\n<p><strong>\u65e0\u9700\u624b\u52a8\u767b\u5f55<\/strong>:<\/p>\n<ul>\n<li>\u4e0d\u9700\u8981\u66b4\u9732 SSH\/RDP \u7aef\u53e3\u5373\u53ef\u7ba1\u7406\u5b9e\u4f8b\uff0c\u51cf\u5c11\u5b89\u5168\u98ce\u9669\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u96c6\u4e2d\u5316\u7ba1\u7406<\/strong>:<\/p>\n<ul>\n<li>\u7ba1\u7406\u5206\u5e03\u5728\u4e0d\u540c\u533a\u57df\u548c\u8d26\u6237\u4e2d\u7684\u5b9e\u4f8b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u81ea\u52a8\u5316<\/strong>:<\/p>\n<ul>\n<li>\u81ea\u52a8\u6267\u884c\u91cd\u590d\u6027\u4efb\u52a1\uff0c\u8282\u7701\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9ad8\u5b89\u5168\u6027<\/strong>:<\/p>\n<ul>\n<li>\u4f7f\u7528\u53c2\u6570\u5b58\u50a8\u52a0\u5bc6\u654f\u611f\u4fe1\u606f\u3002<\/li>\n<li>\u4e0e IAM Role \u96c6\u6210\uff0c\u63d0\u4f9b\u6700\u5c0f\u6743\u9650\u8bbf\u95ee\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8de8\u5e73\u53f0\u652f\u6301<\/strong>:<\/p>\n<ul>\n<li>\u652f\u6301\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\u548c\u672c\u5730\u6570\u636e\u4e2d\u5fc3\u670d\u52a1\u5668\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3><strong>\u603b\u7ed3<\/strong><\/h3>\n<p><strong>AWS SSM<\/strong> \u662f\u4e00\u79cd\u5f3a\u5927\u7684\u7ba1\u7406\u5de5\u5177\uff0c\u7528\u4e8e\u7b80\u5316 AWS \u73af\u5883\u7684\u64cd\u4f5c\u3001\u76d1\u63a7\u548c\u914d\u7f6e\uff0c\u800c <strong>SSM Agent<\/strong> \u662f\u5b83\u7684\u5ba2\u6237\u7aef\u7ec4\u4ef6\uff0c\u8d1f\u8d23\u5728\u5b9e\u4f8b\u6216\u670d\u52a1\u5668\u4e0a\u63a5\u6536\u548c\u6267\u884c\u547d\u4ee4\u3002\u4e8c\u8005\u7ed3\u5408\u63d0\u4f9b\u4e86\u7075\u6d3b\u3001\u81ea\u52a8\u5316\u4e14\u5b89\u5168\u7684\u8d44\u6e90\u7ba1\u7406\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS SSM \u548c SSM Agent \u662f\u4ec0\u4e48\uff1f AWS Systems Manager (SSM) AWS Systems Manager \u662f\u4e00\u9879\u670d\u52a1\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u754c\u9762\uff0c\u7528\u4e8e\u7ba1\u7406 AWS \u8d44\u6e90\uff08\u5982 EC2 \u5b9e\u4f8b\u3001RDS \u6570\u636e\u5e93\uff09\u548c\u672c\u5730\u670d\u52a1\u5668\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7ba1\u7406\u5458\u81ea\u52a8\u5316\u5e38\u89c1\u7ba1\u7406\u4efb\u52a1\uff0c\u4f8b\u5982\u8f6f\u4ef6\u66f4\u65b0\u3001\u914d\u7f6e\u7ba1\u7406\u548c\u7cfb\u7edf\u76d1\u63a7\u3002 SSM Agent SSM Agent \u662f\u5b89\u88c5\u5728 EC2 \u5b9e\u4f8b\u6216\u672c\u5730\u670d\u52a1\u5668\u4e0a\u7684\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u5ba2\u6237\u7aef\u8f6f\u4ef6\uff0c\u7528\u4e8e\u63a5\u6536\u6765\u81ea AWS Systems Manager \u7684\u547d\u4ee4\u5e76\u6267\u884c\u5b83\u4eec\uff0c\u4f8b\u5982\u8fd0\u884c\u811a\u672c\u3001\u5b89\u88c5\u66f4\u65b0\u3001\u6536\u96c6\u65e5\u5fd7\u7b49\u3002 AWS SSM \u7684\u7528\u9014 \u8fdc\u7a0b\u7ba1\u7406: \u5141\u8bb8\u901a\u8fc7 AWS \u63a7\u5236\u53f0\u6216 CLI \u8fdc\u7a0b\u7ba1\u7406 EC2 \u5b9e\u4f8b\u6216\u672c\u5730\u670d\u52a1\u5668\uff0c\u800c\u65e0\u9700\u624b\u52a8\u767b\u5f55\u3002 \u81ea\u52a8\u5316\u4efb\u52a1: \u81ea\u52a8\u5316\u4efb\u52a1\uff0c\u5982\u8865\u4e01\u7ba1\u7406\u3001\u8f6f\u4ef6\u5206\u53d1\u548c\u5b9a\u671f\u5907\u4efd\u3002 \u8fd0\u884c\u547d\u4ee4: \u5728\u591a\u4e2a\u5b9e\u4f8b\u4e0a\u540c\u65f6\u6267\u884c\u811a\u672c\u6216\u547d\u4ee4\u3002 \u914d\u7f6e\u7ba1\u7406: \u4f7f\u7528\u53c2\u6570\u5b58\u50a8\u7ba1\u7406\u914d\u7f6e\u6570\u636e\u548c\u5bc6\u94a5\u3002 \u5408\u89c4\u6027\u548c\u5ba1\u8ba1: \u5b9e\u73b0\u914d\u7f6e\u5408\u89c4\u6027\u68c0\u67e5\u548c\u5ba1\u8ba1\uff0c\u786e\u4fdd\u7cfb\u7edf\u914d\u7f6e\u7b26\u5408\u5b89\u5168\u6807\u51c6\u3002 SSM Agent \u7684\u7528\u9014 \u63a5\u6536\u548c\u6267\u884c\u547d\u4ee4: \u4ece Systems [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=1793\" title=\"Permanent Link to: What are AWS SSM and SSM Agent, how they work?\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1793","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1793"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1793"}],"version-history":[{"count":1,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1793\/revisions"}],"predecessor-version":[{"id":1794,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1793\/revisions\/1794"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}