linux上安装git(客户端)及GitHub的配置
在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的配置