groupadd git
useradd git -g git
yum install git # centos
apt-get install git # ubuntu
su git
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
chown -R git:git .ssh
cat ~/.ssh/id_rsa.pub #在客户端执行
将客户端公钥拷贝到.ssh/authorized_keys
cd /srv #切换到 srv 目录
mkdir gitrepo #新建目录
chown -R git:git /srv/gitrepo
cd /srv/gitrepo
git init --bare project.git
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