由于使用 git 时的权限问题,我尝试以与 root 不同的用户身份运行 cloud init。有这样的办法吗?
使用git时的权限问题
runcmd如果尝试在模块中运行 git 命令,您可以使用su它来选择以哪个用户身份运行该命令。
考虑:
root# su <target user> -c "whoami"
<target user>
Run Code Online (Sandbox Code Playgroud)
我还没有测试过,但你的云配置中类似的东西可能会起作用:
runcmd:
- [su, myuser, -c, "git clone <repo> <directory>"]
Run Code Online (Sandbox Code Playgroud)