centos7搭建git倉庫並開啟RSA認證
阿新 • • 發佈:2019-02-16
1.首先需要安裝Git,可以使用yum源線上安裝:
yum install -y git
2.建立git使用者
adduser git
3.初始化git倉庫並授權
git init --bare test.git
chown git:git test.git
4.開啟RSA認證
/etc/ssh/sshd_config
修改
1.RSAAuthentication yes
2.PubkeyAuthentication yes
3.AuthorizedKeysFile .ssh/authorized_keys
5.重啟sshd
systemctl restart sshd.service
6.建立authorized_keys檔案並授權(如果使用root使用者,則在/home/root/.ssh下建立)
cd /home/git
mkdir .ssh
vim authorized_keys
chmod 700 /home
chmod 700 /home/git
chmod 700 /home/git/.ssh
chmod 600 /home/git/.ssh/authorized_keys
chown git /home
chown git /home/git
chown git /home/git/.ssh
chown git /home/git/.ssh/authorized_keys
7.拷貝公鑰內容到authorized_keys
本地測試連線即成功