目录搜索
GuidesgitattributesgiteverydaygitglossarygitignoregitmodulesgitrevisionsgittutorialgitworkflowsAdministrationgit archivegit bundlegit cleangit filter-branchgit fsckgit gcgit instawebgit reflogBasic Snapshottinggit addgit commitgit diffgit mvgit resetgit rmgit statusBranching and Merginggit branchgit checkoutgit loggit mergegit mergetoolgit stashgit tagDebugginggit bisectgit blamegit grepEmailgit amgit format-patchgit request-pullgit send-emailExternal Systemsgit fast-importgit svnGetting and Creating Projectsgit clonegit initGitgit annotategit archimportgit bisect-lk2009git check-attrgit check-mailmapgit check-ref-formatgit checkout-indexgit cherrygit citoolgit columngit credentialgit credential-cachegit credential-storegit cvsexportcommitgit cvsimportgit cvsservergit diff-filesgit diff-treegit difftoolgit fast-exportgit fetch-packgit fmt-merge-msggit get-tar-commit-idgit guigit http-backendgit http-fetchgit http-pushgit imap-sendgit index-packgit interpret-trailersgit ls-remotegit ls-treegit mailinfogit mailsplitgit merge-filegit merge-indexgit merge-one-filegit merge-treegit mktaggit mktreegit name-revgit notesgit p4git pack-objectsgit pack-redundantgit pack-refsgit parse-remotegit patch-idgit prunegit prune-packedgit quiltimportgit receive-packgit remote-extgit remote-fdgit remote-testgitgit repackgit replacegit rereregit send-packgit sh-i18ngit sh-setupgit shellgit show-branchgit show-indexgit stripspacegit unpack-filegit unpack-objectsgit upload-archivegit upload-packgit vargit verify-commitgit verify-taggit whatchangedgit worktreeInspection and Comparisongit describegit shortloggit showMiscellaneousapi credentialsapi indexgitcligitcore tutorialgitcredentialsgitcvs migrationgitdiffcoregithooksgitkgitnamespacesgitremote helpersgitrepository layoutgitsubmodulesgittutorial 2gitwebgitweb.confpack formatUser ManualPatchinggit applygit cherry-pickgit rebasegit revertPlumbing Commandsgit cat-filegit check-ignoregit commit-treegit count-objectsgit diff-indexgit for-each-refgit hash-objectgit ls-filesgit merge-basegit read-treegit rev-listgit rev-parsegit show-refgit symbolic-refgit update-indexgit update-refgit verify-packgit write-treeServer Admingit daemongit update-server-infoSetup and Configgitgit configgit helpSharing and Updating Projectsgit fetchgit pullgit pushgit remotegit 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
上一篇:下一篇: