butaileng7

参考原文 https://blog.csdn.net/tomatocc/article/details/83933041

1.yum install -y git 安装Git

2.git version 查看Git版本

3.对git进行初始化设置

git config --global user.name "tomatocc" (tomatocc是git的用户名) 然后回车即可
git config --global user.email "tomatocc@sina.com" (tomatocc@sina.com是git的用户名邮箱) 然后回车即可

4. 生成授权证书

Git的授权证书是基于公钥和私钥的证书体系,所以需要证书体系
输入命令 ssh-keygen -t rsa -C "tomatocc@sina.com"生成证书。(1:表示文件名,2:表示生成证书的密码,3:表示确认密码),然后回车即可

 

 5. 切换到ssh目录下 cd ~/.ssh/ 查看证书是否生成

 

 id_rsa 是私钥,id_rsa.pub表示公钥

6.实现git和github的链接

1。将证书注册到github上。
1)首先登陆github,https://github.com/
2)登陆之后点击头像,点击Settings.

 

 3) 然后点击【SSH and GPG Keys】-----> 【New SSH Key】

 

 4) 然后填写SSH Key数据。Title是名字(随便写),Key是我们在上面创建的公钥。

 

 

 

 5)我们回到Linux服务器中,用命令cd ~/.ssh/ 切换到证书文件下,然后勇命令cat id_rsa.pub 查看公钥内容,并复制公钥内容,将该公钥黏贴到github中的key里面,然后点击【Add SSH Key】。

7.验证git的配置是否正确,是否能链接github

1: 使用命令 ssh git@github.com 来链接github,然后回车

 

 

 

 系统会提示是否要连接,我们输入yes,然后回车。当出现上图红方框中的内容时,就表示我们的linux服务器已经和github连接成功。

分类:

技术点:

相关文章: