vps自建git服务器

参考连接:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579bc4b458f044ce7afed3df579123eca000
1、安装git:使用命令 apt-get install git
2、创建git用户,用来运行git服务:使用命令 adduser git
3、创建证书:在服务器/home/git目录下创建文件夹.ssh,然后在.ssh文件夹里创建authorized_keys文件,回头把用户的公钥就放在这个文件里。(用户公钥创建:ssh-keygen,然后找到id_rsa.pub即公钥文件,复制其中的内容到服务器authorized_keys文件)
4、打开服务器RSA验证:进入服务器/etc/ssh目录,编辑sshd_config,修改RSAAuthentication yes,PubkeyAuthentication yes,AuthorizedKeysFile .ssh/authorized_keys
5、新建一个git仓库:新建了一个/home/code文件目录,在该目录下输入命令 git init –bare test.git,即初始化了一个仓库
6、修改owner为git:chown -R git:git test.git
7、禁用shell登录:编辑/etc/passwd文件,把“git:x:1001:1001:,,,:/home/git:/bin/bash”修改为:“git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
8、在本地clone test.git仓库,git clone git@服务器ip:/home/code/test.git

发表评论

邮箱地址不会被公开。 必填项已用*标注