3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.36.1.74.g277cf0bc36
10 .TH "GIT\-SHELL" "1" "05/11/2022" "Git 2\&.36\&.1\&.74\&.g277cf0b" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-shell \- Restricted login shell for Git\-only SSH access
35 \fIchsh\fR \-s $(command \-v git\-shell) <user>
36 \fIgit clone\fR <user>\fB@localhost:/path/to/repo\&.git\fR
37 \fIssh\fR <user>\fB@localhost\fR
42 This is a login shell for SSH accounts to provide restricted Git access\&. It permits execution only of server\-side Git commands implementing the pull/push functionality, plus custom commands present in a subdirectory named \fBgit\-shell\-commands\fR in the user\(cqs home directory\&.
45 \fIgit shell\fR accepts the following commands after the \fB\-c\fR option:
47 \fIgit receive\-pack <argument>\fR, \fIgit upload\-pack <argument>\fR, \fIgit upload\-archive <argument>\fR
49 Call the corresponding server\-side command to support the client\(cqs
52 \fIgit archive \-\-remote\fR
58 Imitate a CVS server\&. See
59 \fBgit-cvsserver\fR(1)\&.
62 If a \fB~/git\-shell\-commands\fR directory is present, \fIgit shell\fR will also handle other, custom commands by running "\fBgit\-shell\-commands/<command> <arguments>\fR" from the user\(cqs home directory\&.
65 By default, the commands above can be executed only with the \fB\-c\fR option; the shell is not interactive\&.
67 If a \fB~/git\-shell\-commands\fR directory is present, \fIgit shell\fR can also be run interactively (with no arguments)\&. If a \fBhelp\fR command is present in the \fBgit\-shell\-commands\fR directory, it is run to provide the user with an overview of allowed actions\&. Then a "git> " prompt is presented at which one can enter any of the commands from the \fBgit\-shell\-commands\fR directory, or \fBexit\fR to close the connection\&.
69 Generally this mode is used as an administrative interface to allow users to list repositories they have access to, create, delete, or rename repositories, or change repository descriptions and permissions\&.
71 If a \fBno\-interactive\-login\fR command exists, then it is run and the interactive shell is aborted\&.
74 To disable interactive logins, displaying a greeting instead:
80 $ chsh \-s /usr/bin/git\-shell
81 $ mkdir $HOME/git\-shell\-commands
82 $ cat >$HOME/git\-shell\-commands/no\-interactive\-login <<\eEOF
84 printf \(aq%s\en\(aq "Hi $USER! You\(aqve successfully authenticated, but I do not"
85 printf \(aq%s\en\(aq "provide interactive shell access\&."
88 $ chmod +x $HOME/git\-shell\-commands/no\-interactive\-login
95 To enable git\-cvsserver access (which should generally have the \fBno\-interactive\-login\fR example above as a prerequisite, as creating the git\-shell\-commands directory allows interactive logins):
101 $ cat >$HOME/git\-shell\-commands/cvs <<\eEOF
102 if ! test $# = 1 && test "$1" = "server"
104 echo >&2 "git\-cvsserver only handles \e"server\e""
107 exec git cvsserver server
109 $ chmod +x $HOME/git\-shell\-commands/cvs
117 ssh(1), \fBgit-daemon\fR(1), contrib/git\-shell\-commands/README
120 Part of the \fBgit\fR(1) suite