在linix上安裝git時可能出現:-bash: git: command not found 錯誤 即找不到命令
Centos 7 64位:
分別執行:
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
Centos 6 32位:
get http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
通過git安裝命令:
yum install -y git
安裝完成進行查看:
git version
輸出了版本號表示安裝成功
為了保證git服務器和我們自己的測試服務器能正常通信所以需要填入公鑰信息
由於git的認證授權是基於公鑰和私鑰的體系,所以需要授權證書來保證測試服務器和git服務器的正常授信
生成授權證書:
ssh-keygen -t rsa -C “xxxxxx@qq.com”
接下來一路enter下一步即可:
通過命令:
cd ~/.ssh/
在通過ls或者ll命令查看列表,可以發現有2個文件:
一個是id_rsa、id_rsa.pub 分別為私鑰和公鑰
通過編輯器:
vim id_rsa.pub
或
cat id_rsa.pub
再將公鑰信息拷貝,接下來登錄GitHub 選擇→settings→SSH and GPG keys →New SSH key,title隨便輸入,將以上拷貝的公鑰信息填入 最后Add SSH key
最后到控制台進行測試:
ssh git@github.com
接下來會看到:
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes
輸入yes
看到如下信息表示成功:
Warning: Permanently added 'github.com,xxxxxx' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi wanghaiy! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
至此就完成了git的安裝與GitHub的配置
