授予对受限 git shell 的访问权限

ehi*_*ime 3 shell ssh centos git

我尝试git-shell在我们的 CentOS (6.4) 系统上进行设置(在 Ubuntu 13.10 上正常工作后,可能是跨平台的热点问题?)

我的/etc/passwd节目

git:x:500:500:Web Archive VCS:/home/git:/usr/bin/git-shell
Run Code Online (Sandbox Code Playgroud)

我的 shell 命令在 /home/git/git-shell-commands

[root@domain git]# cd /home/git/git-shell-commands/ && tree
.
??? addkey
??? create
??? drop
??? help
??? list
Run Code Online (Sandbox Code Playgroud)

但是 ssh'ing in 仍然给我

Last login: Fri Nov 15 12:14:49 2013 from localhost
fatal: What do you think I am? A shell?
Connection to localhost closed.
Run Code Online (Sandbox Code Playgroud)

我正在使用此资源

使用 git-shell 托管一个管理员友好的 git 服务器

有一些混淆,这是许可的 GIT 命令(推/拉等),但这是一个带有预设命令的受限 shell!请任何阅读本文的人注意;)

如果您想查看步骤,则安装程序脚本

https://github.com/ehime/bash-tools/blob/master/git-server-setup.sh

周末我仍然无法解决这个问题,我已经添加了

# add to shells
echo '/usr/bin/git-shell' >> /etc/shells

# Prevent full login for security reasons
chsh -s /usr/bin/git-shell git
Run Code Online (Sandbox Code Playgroud)

并仔细检查了 GIT Shell 确实存在于 /usr/bin

[root@domain bin]# ll /usr/bin | grep git
-rwxr-xr-x. 105 root root    1138056 Mar  4  2013 git
-rwxr-xr-x.   1 root root    1138056 Mar  4  2013 git-receive-pack
-rwxr-xr-x.   1 root root     457272 Mar  4  2013 git-shell
-rwxr-xr-x.   1 root root    1138056 Mar  4  2013 git-upload-archive
-rwxr-xr-x.   1 root root     467536 Mar  4  2013 git-upload-pack
Run Code Online (Sandbox Code Playgroud)

这是我正在处理的根帐户,这可能与它有关吗?

ehi*_*ime 5

事实证明,此功能已在 git 1.7.4 中引入。 git --version在基本的 CentOS 6.4 安装上给了我 1.7.1 所以这是问题的开始=/

如果您遇到此问题,请检查您的 git 版本。这是我编写的更新程序脚本,旨在帮助您解决问题。

#!/bin/bash
# Git updater for RHEL systems

# CPR : Jd Daniel :: Ehime-ken
# MOD : 2013-11-18 @ 09:28:49

# REF : http://goo.gl/ditKWu
# VER : Version 1.1

# ROOT check
if [[ $EUID -ne 0 ]]; then
  echo "This script must be run as su" 1>&2 ; exit 1
fi

yum install -y perl-ExtUtils-MakeMaker gettext-devel expat-devel curl-devel zlib-devel openssl-devel
cd /usr/local/src

git clone git://git.kernel.org/pub/scm/git/git.git && cd git
make && make prefix=/usr install

git --version
exit 0
Run Code Online (Sandbox Code Playgroud)

感谢所有花时间研究此事的人,我非常感谢。