EC2 Bootstrap脚本未在Ubuntu上执行

时间:2017-10-29 21:54:14

标签: amazon-web-services amazon-ec2 user-data

我正在尝试使用以下CLI命令为EC2 Ubuntu机器设置引导脚本:

#cloud-boothook
#!/bin/bash
sudo chmod 750 -R  /home/

以上文本是通过AWS控制台在用户数据中设置的。

一旦机器开始运行,更改模式仍未被上述用户数据脚本修改。

尝试替代命令:

Content-Type: text/cloud-boothook
Content-Type: text/x-shellscript
sudo chmod 750 -R  /home/

静态目录权限不会更改。

我的目标是在机器启动时使用750更改模式设置用户主目录。

我很感激任何解决方案。

以下是出现的错误消息:

[[0;32m  OK  [0m] Started Initial cloud-init job (pre-networking).
[[0;32m  OK  [0m] Reached target Network (Pre).
[[0;32m  OK  [0m] Started ifup for eth0.
         Starting Raise network interfaces...
[[0;32m  OK  [0m] Started Raise network interfaces.
[[0;32m  OK  [0m] Reached target Network.
         Starting Initial cloud-init job (metadata service crawler)...
[    7.535726] cloud-init[1003]: Cloud-init v. 0.7.9 running 'init' at Sun, 29 Oct 2017 19:44:35 +0000. Up 7.23 seconds.
[    7.548260] cloud-init[1003]: ci-info: ++++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++
[    7.565098] cloud-init[1003]: ci-info: +--------+------+-----------------------------+---------------+-------+-------------------+
[    7.580238] cloud-init[1003]: ci-info: | Device |  Up  |           Address           |      Mask     | Scope |     Hw-Address    |
[    7.592760] cloud-init[1003]: ci-info: +--------+------+-----------------------------+---------------+-------+-------------------+
[    7.602150] cloud-init[1003]: ci-info: |   lo   | True |          127.0.0.1          |   255.0.0.0   |   .   |         .         |
[    7.613465] cloud-init[1003]: ci-info: |   lo   | True |           ::1/128           |       .       |  host |         .         |
[    7.625404] cloud-init[1003]: ci-info: |  eth0  | True |        172.31.19.221        | 255.255.240.0 |   .   | 06:ad:ba:ed:47:10 |
[    7.635005] cloud-init[1003]: ci-info: |  eth0  | True | fe80::4ad:baff:feed:4710/64 |       .       |  link | 06:ad:ba:ed:47:10 |
[    7.648580] cloud-init[1003]: ci-info: +--------+------+-----------------------------+---------------+-------+-------------------+
[    7.663022] cloud-init[1003]: ci-info: +++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++
[    7.674192] cloud-init[1003]: ci-info: +-------+-------------+-------------+---------------+-----------+-------+
[    7.682430] cloud-init[1003]: ci-info: | Route | Destination |   Gateway   |    Genmask    | Interface | Flags |
[    7.690935] cloud-init[1003]: ci-info: +-------+-------------+-------------+---------------+-----------+-------+
[    7.703027] cloud-init[1003]: ci-info: |   0   |   0.0.0.0   | 172.31.16.1 |    0.0.0.0    |    eth0   |   UG  |
[    7.712719] cloud-init[1003]: ci-info: |   1   | 172.31.16.0 |   0.0.0.0   | 255.255.240.0 |    eth0   |   U   |
[    7.719950] cloud-init[1003]: ci-info: +-------+-------------+-------------+---------------+-----------+-------+
**[    7.728024] cloud-init[1003]: 2017-10-29 19:44:35,859 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: 'b'Content-Type: text/cloud'...'**
[[0;32m  OK  [0m] Started Initial cloud-init job (metadata service crawler).
[[0;32m  OK  [0m] Reached target Cloud-config availability.
[[0;32m  OK  [0m] Reached target System Initialization.
[[0;32m  OK  [0m] Listening on D-Bus System Message Bus Socket.
         Starting Socket activation for snappy daemon.

1 个答案:

答案 0 :(得分:0)

您正在递归地向/home分配750权限。

750表示:

  • 所有者可以阅读,写作和执行。
  • 本集团可能会阅读并执行。 (但不写)
  • 世界可能对此文件没有任何作用。

/home目录本身归root所有,位于root组。因此,在递归应用750后,只有root可以访问/home的内容(包括其他用户'主目录)。

因此,你真的不想这样做。