Amazon web services 未在Ubuntu上执行EC2引导脚本

Amazon web services 未在Ubuntu上执行EC2引导脚本,amazon-web-services,amazon-ec2,user-data,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/ 仍然没有

我正在尝试使用以下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.

您正在递归地将750权限分配给
/home

750是指:

  • 所有者可以读取、写入和执行
  • 组可以读取和执行。(但不是写)
  • 世界可能不会对这个文件做任何事情
/home
目录本身由
root
所有,并且位于
root
组中。因此,在递归应用750之后,只有
root
可以访问
/home
的内容(包括其他用户的主目录)


因此,您确实不想这样做。

您使用的是哪种AMI?它是否来自EC2启动向导快速启动部分的列表?我使用的是免费的tier T2。这是来自EC2的启动实例选项。它对我有用!事实上,由于更改了
/home
权限,它工作得非常好,我甚至无法登录到该实例!也许你的意图是别的?早上好,约翰,我真的很抱歉你不能再次登录。只是想知道我是否打算更改对主目录的访问权限,因为这是安全要求。如果有其他选择,我将不胜感激。您的实际安全要求是什么?如果您遵循文档化的要求,请共享这些要求。感谢您的回复John,这是我们不提供对非根提供商的所有访问权限的意图。这意味着他们甚至无法登录,因为他们无法访问自己的目录。这也是你的意图吗?即使是
ubuntu
用户也无法登录,因为他们不是
root
。感谢您提供更多信息。我会做更多的研究,并尝试找到替代方案。我感谢你在这方面的帮助。