[英]How can I run shell commands for non-root user during cloud-init configuration?
[英]Can I run cloud init as a different user than root?
由于使用 git 时出现权限问题,我正在尝试以不同于 root 的用户身份运行 cloud init。有这样的方法吗?
要使用 cloud init 使用非 root 用户执行命令,您可以执行以下操作:
runcmd:
- su -c 'whoami' - myuser
使用git时的权限问题
如果尝试在runcmd
模块中运行 git 命令,您可以使用su
来选择以哪个用户身份运行该命令。
考虑:
root# su <target user> -c "whoami"
<target user>
我还没有测试过,但你的云配置中的类似内容可能会起作用:
runcmd:
- [su, myuser, -c, "git clone <repo> <directory>"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.