Skip to content

Instantly share code, notes, and snippets.

@yuezhu
Last active February 8, 2018 20:50
Show Gist options
  • Save yuezhu/2ab041f95b3d2d8022b49312a7a0c635 to your computer and use it in GitHub Desktop.
Save yuezhu/2ab041f95b3d2d8022b49312a7a0c635 to your computer and use it in GitHub Desktop.
Setup SSH GIT server
sudo useradd --create-home --skel /dev/null --home-dir /repo --shell /usr/bin/git-shell git
sudo chmod 750 /repo
sudo mkdir -p /repo/.ssh
sudo cp ~/.ssh/authorized_keys /repo/.ssh/ # Use current user's authorized_keys
sudo chown -R git:git /repo/.ssh/
sudo mkdir -p /repo/git-shell-commands
sudo sh -c "cat >/repo/git-shell-commands/no-interactive-login <<\EOF
#!/bin/sh
printf '%s\n' \"No interactive shell access is provided by this GIT server.\"
exit 128
EOF"
sudo chmod +x /repo/git-shell-commands/no-interactive-login
sudo chown -R git:git /repo/git-shell-commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment