EC2实例-使用Shell 脚本和 cloud-init 指令组合使用 免密钥登录
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
echo "root:XXXXX" | chpasswd
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/" /etc/ssh/sshd_config
sed -i "s/PermitRootLogin forced-commands-only/PermitRootLogin yes/" /etc/ssh/sshd_config
service sshd restart
--//
标签:Userdata,1.0,Content,Version,MIME,EC2,config,cloud,密钥
From: https://blog.51cto.com/u_14169716/6086625