3
我想問一下在啓動的實例上是否有重新執行用戶數據的方法。 我想重新啓動服務並編輯〜。/ ssh/autorized_keys。如何從控制檯重新運行aws ec2上的用戶數據?
我在https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/ 找到信息,但來自控制檯的雲日誌沒有顯示任何更改。
我想問一下在啓動的實例上是否有重新執行用戶數據的方法。 我想重新啓動服務並編輯〜。/ ssh/autorized_keys。如何從控制檯重新運行aws ec2上的用戶數據?
我在https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/ 找到信息,但來自控制檯的雲日誌沒有顯示任何更改。
AWS僅在首次啓動時運行用戶數據。您需要執行以下兩項操作:
write-mime-multipart
中的cloud-utils
來創建mime-multipart文件。如果您需要更多詳細信息,請參閱Cloud-init。scripts-user
運行always
。在/etc/cloud/cloud.cfg
,請參閱Always run cloud-init scripts看所以,你需要從你提供的鏈接複製所有的腳本,並與你更換外殼腳本部分的選項。 https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/
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==