centos7 安装 git服务器

服务器端配置

yum install -y git

groupadd git

useradd git -g git

2.创建authorized_keys

cd /home/git

mkdir .ssh

chmod 700 .ssh

touch .ssh/authorized_keys

chmod 600 .ssh/authorized_keys

cd /home

chown -R git:git git

2.服务器端创建RSA

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile  .ssh/authorized_keys

systemctl restart sshd.serivice

3 服务器端初始化空库

cd /home

mkdir gitreps

chown git:git gitrepo/

cd gitrepo

git init --bar alantop.git

chown -R git:git alantop.git

客户端配置

git clone git@ip:/home/gitrepo/alantop.git

补充:

创建密钥,并将公钥拷贝到服务器的authorized_keys中

服务器客户端均可

ssh-jetgeb -t rsa -C "email"

生成私钥 id_rsa

生成公钥 id_rsa.pub 将此文件写入到服务器的authorized_keys中,这样在git clone时候,就无需密码。

原文地址:https://www.cnblogs.com/alantop/p/11981729.html