Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 1.48 KB

File metadata and controls

77 lines (51 loc) · 1.48 KB

Deploy Git on the Server

  • create user
useradd git
  • assign a password
passwd git
  • init a repertory
git init --bare test.git
  • change owner
chown -R git:git test.git
  • specify git-shell instead of bash for git login shell
cat /etc/shells   # see if `git-shell` is already in there.  If not...
which git-shell   # make sure git-shell is installed on your system.
sudo vim /etc/shells  # and add the path to git-shell from last command
sudo chsh git  # and enter the path to git-shell, usually: /usr/bin/git-shell

Secure Server

  1. Create the user, replacing example_user with your desired username, and assign a password:
useradd example_user && passwd example_user
  1. Add the user to the wheel group for sudo privileges:
usermod -aG wheel example_user
  1. Upload the public key to your server:
ssh-copy-id example_user@255.255.255.255
  1. SSH daemon options:
PermitRootLogin no
PasswordAuthentication no
  1. Restart the SSH service to load the new configuration.
sudo systemctl restart sshd

Reference

如何在 Linux 上搭建一个 Git 中央仓库

gitosis

How to Secure Your Server

Git on the Server - Setting Up the Server