git-shell.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. git-shell(1)
  2. ============
  3. NAME
  4. ----
  5. git-shell - Restricted login shell for Git-only SSH access
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'chsh' -s $(command -v git-shell) <user>
  10. 'git clone' <user>`@localhost:/path/to/repo.git`
  11. 'ssh' <user>`@localhost`
  12. DESCRIPTION
  13. -----------
  14. This is a login shell for SSH accounts to provide restricted Git access.
  15. It permits execution only of server-side Git commands implementing the
  16. pull/push functionality, plus custom commands present in a subdirectory
  17. named `git-shell-commands` in the user's home directory.
  18. COMMANDS
  19. --------
  20. 'git shell' accepts the following commands after the `-c` option:
  21. 'git receive-pack <argument>'::
  22. 'git upload-pack <argument>'::
  23. 'git upload-archive <argument>'::
  24. Call the corresponding server-side command to support
  25. the client's 'git push', 'git fetch', or 'git archive --remote'
  26. request.
  27. 'cvs server'::
  28. Imitate a CVS server. See linkgit:git-cvsserver[1].
  29. If a `~/git-shell-commands` directory is present, 'git shell' will
  30. also handle other, custom commands by running
  31. "`git-shell-commands/<command> <arguments>`" from the user's home
  32. directory.
  33. INTERACTIVE USE
  34. ---------------
  35. By default, the commands above can be executed only with the `-c`
  36. option; the shell is not interactive.
  37. If a `~/git-shell-commands` directory is present, 'git shell'
  38. can also be run interactively (with no arguments). If a `help`
  39. command is present in the `git-shell-commands` directory, it is
  40. run to provide the user with an overview of allowed actions. Then a
  41. "git> " prompt is presented at which one can enter any of the
  42. commands from the `git-shell-commands` directory, or `exit` to close
  43. the connection.
  44. Generally this mode is used as an administrative interface to allow
  45. users to list repositories they have access to, create, delete, or
  46. rename repositories, or change repository descriptions and
  47. permissions.
  48. If a `no-interactive-login` command exists, then it is run and the
  49. interactive shell is aborted.
  50. EXAMPLES
  51. --------
  52. To disable interactive logins, displaying a greeting instead:
  53. ----------------
  54. $ chsh -s /usr/bin/git-shell
  55. $ mkdir $HOME/git-shell-commands
  56. $ cat >$HOME/git-shell-commands/no-interactive-login <<\EOF
  57. #!/bin/sh
  58. printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not"
  59. printf '%s\n' "provide interactive shell access."
  60. exit 128
  61. EOF
  62. $ chmod +x $HOME/git-shell-commands/no-interactive-login
  63. ----------------
  64. To enable git-cvsserver access (which should generally have the
  65. `no-interactive-login` example above as a prerequisite, as creating
  66. the git-shell-commands directory allows interactive logins):
  67. ----------------
  68. $ cat >$HOME/git-shell-commands/cvs <<\EOF
  69. if ! test $# = 1 && test "$1" = "server"
  70. then
  71. echo >&2 "git-cvsserver only handles \"server\""
  72. exit 1
  73. fi
  74. exec git cvsserver server
  75. EOF
  76. $ chmod +x $HOME/git-shell-commands/cvs
  77. ----------------
  78. SEE ALSO
  79. --------
  80. ssh(1),
  81. linkgit:git-daemon[1],
  82. contrib/git-shell-commands/README
  83. GIT
  84. ---
  85. Part of the linkgit:git[1] suite