Git Server

来源:互联网 发布:淘宝mac版官方下载 编辑:程序博客网 时间:2024/06/07 13:01

在前面的文章中,为大家介绍了如何自己架设一个git服务器并建立一个名为git的用户来进行所有的git操作。

那么如果我们想限制git用户,禁止其进行SSH登陆进行操作,我们可以将git用户的shell换成git-shell这个工具:

$ cat /etc/shells   # see if `git-shell` is already in there.  If not...$ which git-shell   # make sure git-shell is installed on your system.$ sudo vim /etc/shells  # and add the path to git-shell from last command

我们看到,首先需要找到git-shell的安装位置,如果没有被添加在/etc/shells中,我们需要手动将其添加进去(通常git-shell/usr/bin/git-shell中)。

接下来,我们就可以把默认的shell替换成git-shell了:

$ sudo chsh git -s $(which git-shell)

现在,git用户只能使用SSH连接来进行pushpull,而不能用来登陆服务器了。

$ ssh git@gitserverfatal: Interactive git shell is not enabled.hint: ~/git-shell-commands should exist and have read and execute access.Connection to gitserver closed.
原创粉丝点击