目录 搜索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
文字

名称

git-shell  - 仅限 Git-SSH 访问的受限登录 shell

概要

chsh -s $(command -v git-shell) <user>git clone <user>@localhost:/path/to/repo.git
ssh <user>@localhost

描述

这是 SSH 帐户的登录外壳,用于提供受限制的 Git 访问。它只允许执行实现拉/推功能的服务器端 Git 命令,以及git-shell-commands在用户主目录中命名的子目录中存在的自定义命令。

命令

git shell-c选项后接受以下命令:

git receive-pack <argument>   git upload-pack <argument>   git upload-archive <argument>

调用相应的服务器端命令,以支持客户端的git pushgit fetchgit archive --remote请求。

cvs server

模仿 CVS 服务器。参见 git-cvsserver [1]。

如果存在~/git-shell-commands目录,则git shell还将通过在用户的主目录中运行“ git-shell-commands/<command> <arguments>”来处理其他自定义命令。

交互式使用

默认情况下,上述命令只能使用该-c选项执行; 该 shell 不是交互式的。

如果~/git-shell-commands目录存在,git shell也可以交互式运行(不带参数)。如果目录中help存在命令git-shell-commands,则会向用户提供允许的操作概述。然后出现一个“git>”提示符,用户可以输入git-shell-commands目录中的任何命令或exit关闭连接。

通常,此模式用作管理界面,以允许用户列出他们有权访问的存储库,创建,删除或重命名存储库,或更改存储库描述和权限。

如果no-interactive-login命令存在,则运行它并交互式 shell 被中止。

示例

To disable interactive logins, displaying a greeting instead:

$ chsh -s /usr/bin/git-shell
$ mkdir $HOME/git-shell-commands
$ cat >$HOME/git-shell-commands/no-interactive-login <<\EOF
#!/bin/sh
printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not"printf '%s\n' "provide interactive shell access."exit 128EOF
$ chmod +x $HOME/git-shell-commands/no-interactive-login

要启用 git-cvsserver 访问权限(通常应该有上述no-interactive-login示例作为先决条件,因为创建 git-shell-commands 目录允许交互式登录):

$ cat >$HOME/git-shell-commands/cvs <<\EOFif ! test $# = 1 && test "$1" = "server"then
        echo >&2 "git-cvsserver only handles \"server\""
        exit 1fi
exec git cvsserver server
EOF
$ chmod +x $HOME/git-shell-commands/cvs
上一篇: 下一篇: