aws上安装ssm-agent

aws-cloudwatch

aws-linux安装ssm-agent

使用 SSM 代理查找 AMI 预装

  • 先运行:systemctl status amazon-ssm-agent 查看sshm-agent的状态。
  • 然后安装提示,执行 systemctl start amazon-ssm-agent 启动即可

使用 SSM Agent 日志文件进行故障排除

text 复制代码
root@ip-172-31-1-212 ~]# tail -f /var/log/amazon/ssm/amazon-ssm-agent.log
  <h1>404 - Not Found</h1>
 </body>
</html>

	status code: 404, request id: 
2024-11-19 07:09:10.4718 ERROR EC2RoleProvider Failed to connect to Systems Manager with SSM role credentials. error calling RequestManagedInstanceRoleToken: AccessDeniedException: Systems Manager's instance management role is not configured for account: 850995553350
	status code: 400, request id: 894ea524-6f26-4ac7-ab48-935483e83c06
2024-11-19 07:09:10.4719 ERROR [CredentialRefresher] Retrieve credentials produced error: no valid credentials could be retrieved for ec2 identity. Default Host Management Err: error calling RequestManagedInstanceRoleToken: AccessDeniedException: Systems Manager's instance management role is not configured for account: 850995553350
	status code: 400, request id: 894ea524-6f26-4ac7-ab48-935483e83c06
2024-11-19 07:09:10.4719 INFO [CredentialRefresher] Sleeping for 28m58s before retrying retrieve credentials
2024-11-19 07:38:08.4797 WARN EC2RoleProvider Failed to connect to Systems Manager with instance profile role credentials. Err: retrieved credentials failed to report to ssm. Error: EC2RoleRequestError: no EC2 instance role found
caused by: EC2MetadataError: failed to make EC2Metadata request
<?xml version="1.0" encoding="iso-8859-1"?>

配置步骤

  1. 检查 IAM 角色
    确保你的 EC2 实例已绑定一个 IAM 角色。
    在 AWS 管控台,导航到 EC2 > 实例 > 安全 > 修改 IAM 角色。
    如果未绑定角色,需绑定一个角色(如:SSM-Managed-Instance-Role)。
  2. 附加权限策略
    进入 IAM 控制台,执行以下操作:

找到角色:

在左侧导航中选择 角色,然后找到分配给 EC2 实例的 IAM 角色。

添加策略:

编辑角色权限,搜索并添加以下策略:

AmazonSSMManagedInstanceCore

(可选)CloudWatchAgentServerPolicy

如果需要自定义策略,则根据上文复制策略内容并保存。

  1. 重新启动 Amazon SSM Agent

SSH 登录到 EC2 实例后,执行以下命令:

复制代码
sudo systemctl restart amazon-ssm-agent

选择AmazonSSMManagedInstanceCore 权限

  • 然后去实例中选择实例-->操作-->安全--->修改IAM角色,修改你新建的即可

配置修改完毕后一定要记得重启systemctl restart amazon-ssm-agent

shell 复制代码
sudo systemctl restart amazon-ssm-agent
相关推荐
带你去吃小豆花4 小时前
在亚马逊云科技上使用n8n快速构建个人AI NEWS助理
人工智能·科技·ai·云原生·aws
AWS官方合作商17 小时前
实战解析:基于AWS Serverless架构的高并发微服务设计与优化
架构·serverless·aws
TiAmo zhang3 天前
DeepSeek-R1 模型现已在亚马逊云科技上提供
人工智能·云计算·aws
struggle20256 天前
AWS Bedrock 多代理蓝图存储库使用 CDK、Streamlit 和 LangFuse 运行 AWS Bedrock 多代理 AI 协作的蓝图
运维·人工智能·自动化·云计算·aws
Revendell6 天前
AWS Aurora存算分离架构
aws
李兆龙的博客6 天前
从一到无穷大 #44:AWS Glue: Data integration + Catalog
云计算·aws
sealaugh326 天前
aws(学习笔记第三十六课) apigw-http-api-lambda-dynamodb
笔记·学习·aws
AWS官方合作商7 天前
突破数据迁移瓶颈!AWS Snowball如何让PB级数据“瞬间”上云?
云计算·aws
AWS官方合作商7 天前
AWS混合云部署实战:打造企业级数字化转型的“黄金架构”
云计算·aws
AWS官方合作商7 天前
AWS CloudWatch 实战:构建智能监控与自动化运维体系
运维·自动化·aws