Linux服务器

推荐列表 站点导航

当前位置:首页 > 服务器技术 > Linux服务器 >

Git Server-限制Git用户使用SSH登陆操作

来源:网络整理  作者:fen  发布时间:2020-12-25 13:14
在前面的文章中(http://www.linuxdiyf.com/linux/31490.html),为大家介绍了如何自己架设一个Git服务器并建立一个名为git的用...

在前面的文章中(),为大家介绍了如何自己架设一个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连接来进行push和pull,而不能用来登陆服务器了。

$ ssh git@gitserver

fatal: Interactive git shell is not enabled.

hint: ~/git-shell-commands should exist and have read and execute access.

Connection to gitserver closed.

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/server/fwq/8900.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

Git Server-限制Git用户使用SSH登陆操作

2020-12-25 编辑:fen

在前面的文章中(),为大家介绍了如何自己架设一个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连接来进行push和pull,而不能用来登陆服务器了。

$ ssh git@gitserver

fatal: Interactive git shell is not enabled.

hint: ~/git-shell-commands should exist and have read and execute access.

Connection to gitserver closed.

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/server/fwq/8900.shtml

相关文章

风云图片

推荐阅读

返回Linux服务器频道首页