作为 root,我想以服务用户(jenkins - CI 服务器)的身份登录并使用其用户、组和 umask 设置操作文件。
通常我会(以 root 身份)做sudo -i -u jenkins,甚至su - jenkins. 但是 jenkins 的默认 shell 是 /bin/false,它会立即退出。
有没有办法以 Jenkins 身份登录但指定要使用的不同 shell?我真的必须改变詹金斯的外壳/etc/passwd/吗?
linux 上的 su 支持使用--shell选项设置 shell
su jenkins --shell=/bin/bash
Run Code Online (Sandbox Code Playgroud)
您需要以 root 身份 su 才能正常工作。从手册页:
If the target user has a restricted shell (i.e. the shell field of
this users entry in /etc/passwd is not listed in /etc/shell), then
the --shell option or the $SHELL environment variable wont be taken
into account, unless su is called by root.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1815 次 |
| 最近记录: |