Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何从控制台重新运行aws ec2上的用户数据?_Amazon Web Services_Amazon Ec2_User Data_Cloud Init - Fatal编程技术网

Amazon web services 如何从控制台重新运行aws ec2上的用户数据?

Amazon web services 如何从控制台重新运行aws ec2上的用户数据?,amazon-web-services,amazon-ec2,user-data,cloud-init,Amazon Web Services,Amazon Ec2,User Data,Cloud Init,我想问一下,是否有办法在已启动的实例上重新执行用户数据。 我想重新启动服务并编辑~./ssh/autorized_密钥 我在 但是控制台的云日志没有显示任何更改。AWS仅在第一次启动时运行用户数据。您需要做以下两件事: 使用mime multipart附加新脚本。您可以在cloud utils中使用命令write mime multipart来创建mime multipart文件。如果您需要更多详细信息,请参阅 使用mime multipart设置脚本用户始终运行。在/etc/cloud/clo

我想问一下,是否有办法在已启动的实例上重新执行用户数据。 我想重新启动服务并编辑~./ssh/autorized_密钥

我在
但是控制台的云日志没有显示任何更改。

AWS仅在第一次启动时运行用户数据。您需要做以下两件事:

  • 使用mime multipart附加新脚本。您可以在
    cloud utils
    中使用命令
    write mime multipart
    来创建mime multipart文件。如果您需要更多详细信息,请参阅
  • 使用mime multipart设置
    脚本用户
    始终运行
    。在
    /etc/cloud/cloud.cfg
    中,请参阅查看选项
  • 因此,您需要从提供的链接复制所有脚本,并用您的替换shell脚本部分

    Content-Type: multipart/mixed; boundary="===============5940869395195845375=="
    MIME-Version: 1.0
    
    --===============5940869395195845375==
    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]
    
    --===============5940869395195845375==
    Content-Type: text/x-shellscript; charset="us-ascii"
    MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Content-Disposition: attachment; filename="userdata.txt"
    
    #!/bin/bash
    /bin/echo "Hello World." >> /tmp/abcde
    --===============5940869395195845375==