34

Linux上为git无交互添加最低权限的使用用户

 5 years ago
source link: http://ourjs.com/detail/5b7f6547ac52fe63eba50297?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Git是基于SSH,即能通过用户名密码登录git的用户,一般也是能通过ssh/putty登录linux服务器的,这时我们可能需要创建一个最低权限的Linux用户,让其只能执行git的相关指令,而无法登录ssh。

这时我们可以通过adduser时指定shell来实现,如

adduser --disabled-login --disabled-password --no-create-home -shell /usr/bin/git-shell test110

test110 将禁用登录,禁用密码,不创建用户文件夹,指定shell为git-shell

但这条指定创建用户时还需要交互输入Full Name等用户信息,我们可以通过--gecos "",来默认为空,同时我们可以让其默认添加到 git_group_1 组中,不创建新的用户组,如

adduser --disabled-login --disabled-password --no-create-home -shell /usr/bin/git-shell --gecos "" --ingroup git_group_1 test111

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK