Setup Git Server
更新日期:
文章目录
Create git user
12345$ sudo adduser git$ su git$ cd$ mkdir .ssh && chmod 700 .ssh$ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
Add ssh key for client user
1$ cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys
Create new git repository
1234$ mkdir -p /opt/git/project.git$ cd /opt/git/project.git$ git init --bareInitialized empty Git repository in /opt/git/project.git/
Prevent SSH login of git user
1234$ 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
Done
12$ git clone git@gitserver:/opt/git/project.git$ cd project