溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Git配置(二)Windows安裝Git,并配置Centos

發(fā)布時間:2020-05-24 09:00:52 來源:網(wǎng)絡 閱讀:2000 作者:ligeo5210 欄目:軟件技術

1、為Centos系統(tǒng)創(chuàng)建Git用戶

useradd -d /home/git git      #創(chuàng)建git用戶
passwd git                           #修改密碼

2、打開Centos系統(tǒng)RAS認證

vim /etc/ssh/sshd_config

打開以下注釋,修改如下
Git配置(二)Windows安裝Git,并配置Centos

3、下載windows版本Git安裝軟件,根據(jù)操作系統(tǒng)選擇32位或64位

https://git-scm.com/download/win

4、安裝Git,一直下一步
5、生成windows的ssh key,在目錄點右鍵,選擇Git Bash Here,在打開的命令行輸入以下命令,一路確認

ssh-keygen -t rsa -C "youremail@example.com"

6、上傳ssh key至Centos系統(tǒng),在Windows的Git Bash中輸入以下命令

ssh git@192.168.106.129 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

成功后檢查Centos系統(tǒng)/home/git/.ssh/目錄下是否生成authorized_keys文件,以及該文件中是否有Windows的id_rsa.pub公鑰內容,文件位于C:\Users\xxx.ssh目錄下

7、配置sshd服務

vim /etc/ssh/sshd_config

修改一下內容

PermitRootLogin no
UsePAM no
PasswordAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes

重啟服務

systemctl restart sshd.service

8、在Centos系統(tǒng)創(chuàng)建版本庫

su git
cd /home/git/
mkdir repository
cd repository
mkdir test.git
git init --bare test.git

9、禁止git用戶登陸shell,后續(xù)創(chuàng)建版本庫可由root用戶創(chuàng)建,創(chuàng)建完chown為git用戶

vim /etc/passwd

Git配置(二)Windows安裝Git,并配置Centos
10、通過Windows遠程clone版本庫,在Windows創(chuàng)建要clone的目錄,打開Git Bash,輸入

git init
git clone git@192.168.106.129:/home/git/repository/test.git
向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI