我正在尝试使用ssh-keys和git-shell设置一个安全的git存储库服务器。 由于我们的用户数据库存储在一个中央LDAP目录中,所以我不能将用户的默认shell更改为git-shell,所以我尝试了在authorized_users文件中将公共密钥git-shell命令添加到前面:
command="git-shell -c $SSH_ORIGINAL_COMMAND" ssh-dss AAAAB3NzaC1kc3...
但是,git-shell甚至不允许我克隆版本库:
dhcp202:git-ws frank$ git clone ssh://gitserver/var/repos/git/myrepo/ Cloning into myrepo... fatal: What do you think I am? A shell? fatal: The remote end hung up unexpectedly
任何想法赞赏…
你会发现基于ssh和强制命令的 gitolite类似的机制。
(包括ldap查询 )。
它不允许交互式shell, 这可能是你的问题 。
OP Frank Frank Brenner补充道:
嗯,我明白了 – 命令必须用单引号。 我想在git-shell启动之前,
$SSH_ORIGINAL_COMMAND已经被扩展了。
这是在gitolite强制命令脚本中确认是一个Perl,结束于:
# ---------------------------------------------------------------------------- # over to git now # ---------------------------------------------------------------------------- if ($ENV{REQUEST_URI}) { log_it($ENV{REQUEST_URI}); exec $ENV{GIT_HTTP_BACKEND}; # the GIT_HTTP_BACKEND env var should be set either by the rc file, or as # a SetEnv in the apache config somewhere } log_it(); $repo = "'$REPO_BASE/$repo.git'"; exec("git", "shell", "-c", "$verb $repo") unless $verb eq 'git-init';
请注意$repo = "'$REPO_BASE/$repo.git'"行:它包含单引号。
我使用LDAP,OpenSSH(> 4.9)和git-shell做了一个解决scheme。
OpenSSH的ForceCommand是完美的工作。 考虑下面的configuration(除pipe理员之外的所有人都必须使用git-shell):
Match group *,!admin ForceCommand /usr/bin/git-shell -c "$SSH_ORIGINAL_COMMAND"
访问控制是使用ACL-s和reponame访问组来定义的。
setfacl -bR -m default:group:$REPONAME:rwX -m group:$REPONAME:rwX $GITROOT/$REPONAME setfacl -R -m default:group:$REPONAME-ro:rX -m group:$REPONAME-ro:rX $GITROOT/$REPONAME
不要忘记在每次更改之后运行“nscd -i组”。
安道尔