我正在尝试使用 ssh-keys 和 git-shell 设置安全的 git 存储库服务器。由于我们的用户数据库存储在中央 LDAP 目录中,我无法将用户的默认 shell 更改为 git-shell,因此我尝试将 git-shell 命令添加到 authorized_users 文件中的公钥,如下所示:
command="git-shell -c $SSH_ORIGINAL_COMMAND" ssh-dss AAAAB3NzaC1kc3...
Run Code Online (Sandbox Code Playgroud)
但是,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
Run Code Online (Sandbox Code Playgroud)
任何想法表示赞赏...
您会发现与gitolite类似的机制,基于 ssh 和强制命令。
(包括LDAP 查询)。
但是它不允许交互式 shell,这可能是你的问题。
OP Frank Brenner补充道:
啊,我明白了 - 命令必须用单引号引起来。我想
$SSH_ORIGINAL_COMMAND在 git-shell 启动之前已经得到了扩展。
在 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';
Run Code Online (Sandbox Code Playgroud)
请注意该$repo = "'$REPO_BASE/$repo.git'"行:它确实包含单引号。
| 归档时间: |
|
| 查看次数: |
3322 次 |
| 最近记录: |