GIT服務(wù)器安裝手冊(cè)

1.1.獲取所需軟件包

? ? ?git-2.4.2.tar.gz 下載地址去網(wǎng)上找找就好了,這里就不給出了

1.2.安裝步驟

1.2.1.創(chuàng)建賬戶并配置環(huán)境變量

創(chuàng)建git賬戶

? ? test@git>su - root

? ? root@git>useradd -d /home/git-mgit ??????#創(chuàng)建git用戶

? ? root@>passwdgit#設(shè)置git用戶的密碼為:123456

登入git

? ? root@git>su -git

創(chuàng)建目錄

? ? ?git@git>mkdir git#創(chuàng)建git服務(wù)器的根目錄

? ? git@git>mkdir software#創(chuàng)建software目錄用于存放安裝用的軟件

1.2.2.安裝軟件包

1.2.2.1 上傳軟件包

? ?首先使用git用戶名登錄。

? ? ? ? ?進(jìn)行uname -a查看系統(tǒng)的版本和位數(shù)。

? ? ? ? ?上傳git-2.5.6.tar.gz到git賬戶的$HOME/software目錄下。

? ?以下安裝基于64位系統(tǒng)進(jìn)行安裝,如果系統(tǒng)為32位,只需更改軟件包的名稱

1.2.2.2 安裝Git

[git@eb6381 ~]$ cd software/

[git@eb6381 software]$ tar zxf git-2.5.6.tar.gz

[git@eb6381 software]$ mv git-2.5.6/ /home/git

[git@eb6381 software]$ cd

[git@eb6381 ~]$ ls

git ?git-2.5.6 ?software

|? ? ? ? + o ...o|

| ??????. ?o ??.o.|

| ?????o S ?. ?. o|

| ??????o .E. o . |

| ?????. = . . . ?|

| ??????* . ??????|

| ???????o ???????|

+-----------------+

[git@eb6381 ~]$ cd .ssh/

[git@eb6381 .ssh]$ ls

id_rsa ?id_rsa.pub

服務(wù)器端Git打開RSA認(rèn)證

[git@eb6381 data]$ su root

Password:

[root@eb6381 data]# cd /etc/ssh

[root@eb6381 ssh]# vi sshd_config

#打開以下幾行注釋,保存并退出

HostKey /etc/ssh/ssh_host_key

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile ?????.ssh/authorized_keys

#重啟sshd服務(wù)

[root@eb6381 ssh]# service sshd restart

Stopping sshd: ????????????????????????????????????????????[ ?OK ?]

Starting sshd: ????????????????????????????????????????????[ ?OK ?]

???客戶端clone倉(cāng)庫(kù)

[git@eb6380 ~]$ git clone ssh://10.1.63.81:22/home/git/git/git-2.5.6/data/git/gittest.git

Cloning into 'gittest'...

git@10.1.63.81's password:

warning: You appear to have cloned an empty repository.

Checking connectivity... done.

[git@eb6380 ~]$ ls

git ?gittest ?git_test ?httpd-2.4.27 ?software


ssh-keygen–t rsa? //生成public key(id_rsa.pub)

在git用戶git家目錄下新建一下文件:(有.ssh文件夾可以不用建,沒有就建立一下)

/home/git/.ssh/authorized_keys

將id_rsa.pub內(nèi)容添加到authorized_keys中;

在另一臺(tái)linux上測(cè)試git clone

??

[git@eb6381 ~]$ cd git-2.5.6/

[git@eb6381 git-2.5.6]$ ./configure

[git@eb6381 git-2.5.6]$ make

[git@eb6381 git-2.5.6]$ su root

Password:

[root@eb6381 git-2.5.6]# make install

[root@eb6381 git-2.5.6]# exit

[git@eb6381 git-2.5.6]$ git --version

git version 2.5.6

顯示以上并是安裝成功

1.2.2.3.服務(wù)器端創(chuàng)建git倉(cāng)庫(kù)

1.設(shè)置Git倉(cāng)庫(kù) 然后把Git倉(cāng)庫(kù)owner改成Git用戶

[git@eb6381 git-2.5.6]$ mkdir -p data/gittest.git

[git@eb6381 git-2.5.6]$ git init --bare data/gittest.git

Initialized empty Git repository in /home/git/git-2.5.6/data/gittest.git/

[git@eb6381 git-2.5.6]$ cd data/

[git@eb6381 data]$ chown -R git:git gittest.git/

[git@eb6381 data]$ ll -a

total 12

drwxrwxr-x 3 git git 4096 Jul 13 16:31 .

drwxrwxr-x 3 git git 4096 Jul 13 16:31 ..

drwxrwxr-x 7 git git 4096 Jul 13 16:32 gittest.git

1.2.2.4.客戶端clone遠(yuǎn)程倉(cāng)庫(kù)

生成公匙與私匙方法

[git@eb6381 ~]$ git config --global user.name "hanhan"? #設(shè)置git? username

[git@eb6381 ~]$ git config --global user.email"123456789@qq.com"#設(shè)置git的email

[git@eb6381 ~]$ ssh-keygen -t rsa -C "123456789qq.com" ??#生成git密鑰

Generating public/private rsa key pair.

Enter file in which to save the key (/home/git/.ssh/id_rsa):

Created directory '/home/git/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/git/.ssh/id_rsa.

Your public key has been saved in /home/git/.ssh/id_rsa.pub.

The key fingerprint is:

38:3f:4e:0e:d7:5d:5e:4d:78:c5:cd:ac:20:e6:81:bf 123456789qq.com

The key's randomart image is:

+--[ RSA 2048]----+

| ????????. ????+o|

| ???????. + . ?.*|


[root@localhost ~]# git clone ssh://git@192.168.0.109/data/gittest.git

Cloning into 'gittest'...

warning: You appear to have cloned an empty repository.

[root@localhost ~]# ls

gittest

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容