centos git仓库搭建
1、git安装
yum -y install git
2、创建git用户组
groupadd git
useradd git -g git
3、创建证书登录
收集所有需要登录的用户的公钥,公钥位于id_rsa.pub文件中,把我们的公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
4、Git服务器打开RSA认证
然后就可以去Git服务器上添加你的公钥用来验证你的信息了。在Git服务器上首先需要将/etc/ssh/sshd_config中将RSA认证打开,即:
1.RSAAuthentication yes
2.PubkeyAuthentication yes
3.AuthorizedKeysFile .ssh/authorized_keys
5、创建 .shh 文件
cd /home/git
mkdir .ssh
chown -R git:git .ssh
6、生成秘钥上传到服务器
回到客户端gitBash
ssh-keygen -t rsa -C “youremail@example.com”
ssh git@10.10.161.119 ‘cat >> .ssh/authorized_keys’ < ~/.ssh/id_rsa.pub
7、文件权限
chmod 700 .ssh
cd .ssh
chmod 600 authorized_keys
在/home/gitrepo目录下输入命令:
cd /home
mkdir gitrepo
chown git:git gitrepo/
cd gitrepo
8、建git仓库
$ git init --bare learngit.git
Initialized empty Git repository in /home/gitrepo/learngit.git/
以上命令Git创建一个空仓库,服务器上的Git仓库通常都以.git结尾。然后,把仓库所属用户改为git:
chown -R git:git learngit.git
9、关闭SELinux
setenforce 0
最后
git clone git@10.10.161.119:/home/gitrepo/learngit.git