LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-shell

Restricted login shell for Git-only SSH access

TLDR

Set user shell to git-shell
$ chsh -s $(which git-shell) [git-user]
copy
Run allowed command
$ git-shell -c "git-receive-pack '/repo.git'"
copy

SYNOPSIS

git-shell [-c command]

DESCRIPTION

git-shell is a restricted login shell that allows only Git operations (push, pull, fetch) over SSH while blocking general shell access. When set as a user's login shell, it prevents interactive login while permitting Git protocol operations.This is the standard way to create secure Git hosting accounts that can only interact through Git commands.

PARAMETERS

-c COMMAND

Execute git command.
--help
Display help information.

CONFIGURATION

~/git-shell-commands/

Optional directory of allowed interactive commands. If present, git-shell provides a limited interactive mode listing these commands. A file named `no-interactive-login` in this directory (or anywhere on PATH) fully disables interactive login, printing its contents instead.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Login shell, not a command. Only allows git commands. Used for git server accounts.

HISTORY

git-shell was created to enable secure git hosting by providing a restricted shell that only permits git operations.

SEE ALSO

git(1), ssh(1), chsh(1)

RESOURCES

Copied to clipboard
Kai