1GIT-SHELL(1)                      Git Manual                      GIT-SHELL(1)
2
3
4

NAME

6       git-shell - Restricted login shell for Git-only SSH access
7

SYNOPSIS

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

DESCRIPTION

15       This is a login shell for SSH accounts to provide restricted Git
16       access. It permits execution only of server-side Git commands
17       implementing the pull/push functionality, plus custom commands present
18       in a subdirectory named git-shell-commands in the user’s home
19       directory.
20

COMMANDS

22       git shell accepts the following commands after the -c option:
23
24       git receive-pack <argument>, git upload-pack <argument>, git
25       upload-archive <argument>
26           Call the corresponding server-side command to support the client’s
27           git push, git fetch, or git archive --remote request.
28
29       cvs server
30           Imitate a CVS server. See git-cvsserver(1).
31
32       If a ~/git-shell-commands directory is present, git shell will also
33       handle other, custom commands by running "git-shell-commands/<command>
34       <arguments>" from the user’s home directory.
35

INTERACTIVE USE

37       By default, the commands above can be executed only with the -c option;
38       the shell is not interactive.
39
40       If a ~/git-shell-commands directory is present, git shell can also be
41       run interactively (with no arguments). If a help command is present in
42       the git-shell-commands directory, it is run to provide the user with an
43       overview of allowed actions. Then a "git> " prompt is presented at
44       which one can enter any of the commands from the git-shell-commands
45       directory, or exit to close the connection.
46
47       Generally this mode is used as an administrative interface to allow
48       users to list repositories they have access to, create, delete, or
49       rename repositories, or change repository descriptions and permissions.
50
51       If a no-interactive-login command exists, then it is run and the
52       interactive shell is aborted.
53

EXAMPLES

55       To disable interactive logins, displaying a greeting instead:
56
57           $ chsh -s /usr/bin/git-shell
58           $ mkdir $HOME/git-shell-commands
59           $ cat >$HOME/git-shell-commands/no-interactive-login <<\EOF
60           #!/bin/sh
61           printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not"
62           printf '%s\n' "provide interactive shell access."
63           exit 128
64           EOF
65           $ chmod +x $HOME/git-shell-commands/no-interactive-login
66
67
68       To enable git-cvsserver access (which should generally have the
69       no-interactive-login example above as a prerequisite, as creating the
70       git-shell-commands directory allows interactive logins):
71
72           $ cat >$HOME/git-shell-commands/cvs <<\EOF
73           if ! test $# = 1 && test "$1" = "server"
74           then
75                   echo >&2 "git-cvsserver only handles \"server\""
76                   exit 1
77           fi
78           exec git cvsserver server
79           EOF
80           $ chmod +x $HOME/git-shell-commands/cvs
81
82

SEE ALSO

84       ssh(1), git-daemon(1), contrib/git-shell-commands/README
85

GIT

87       Part of the git(1) suite
88
89
90
91Git 2.18.1                        05/14/2019                      GIT-SHELL(1)
Impressum