Run command on ec2-instance

Install ssm agent on ec2, therefore we can run any shell cmd on this ec2.

I. install ssm agent on ec2:

1.login fcgi ec2(ec2 you have, save as a AMI is better), run sudo su

2. mkdir /tmp/ssm

3.cd /tmp

4.yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm

5.status amazon-ssm-agent (RHEL 6.x); sudo systemctl status amazon-ssm-agent (RHEL 7.x)

6.check logs:

/var/log/amazon/ssm/amazon-ssm-agent.log

/var/log/amazon/ssm/error.log

II. create new IAM role for ssm.

1.change to IAM console, create new role, select AmazonSSMFullAccess and other you need. the created role is: dcs-asg-ssm-iam

2.take FCGI ec2 change the IAM to dcs-asg-ssm-iam.

3.restart FCGI ec2-instance.

4.check logs in /var/log/amazon/ssm/ folder.

III. Run commond on ec2.

1.ec2 consloe->Run Command->Run a Command->AWS-RunShellScript

2.you will see FCGI instance ID, choose it if there are many IDs.

3.Command*: insert your shell, as cd /var/log/amazon/;mkdir deng/

4.click run

5.ssh fcgi ec2, you will see the cmd exe in this ec2, as folder "deng" created

Finish.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,837评论 18 139
  • Awesome Ruby Toolbox Awesome A collection of awesome Ruby...
    debbbbie阅读 2,914评论 0 3
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,906评论 0 0
  • 2016.12.31.22:00,點了一份黃燜雞,這是我的跨年晚餐~ 這個時間點配上這張圖,一般人會覺得很悲催,照...
    1f010e4b2e05阅读 165评论 0 0