git的安装

  1. 安装Git

yum install git

  1. 生成SSH密钥

(设置全局变量)

git config –global user.name “xxx”     # 你的git用户名

git config –global user.email “xxx@xxx.com”    # git的邮箱

ssh-keygen -t rsa -C “your email address”    # 邮箱地址

然后连续按三个回车得到 id_rsa 和 id_rsa.pub 文件,在/root/.ssh 下说明生成成功

  1. 添加密钥到Github

在网页中登录你的Github

点击自己的头像->settings->SSH And GPG Keys->New SSH key 

id_rsa.pub 中的内容($ cat ~/.ssh/id_rsa.pub #此命令可查看key内容)粘贴到 Key 文本框中,随意输入一个 title(不要有中文),点击 Add Key 即可

 

 

 

测试

在命令行中输入

ssh git@github.com

 

会出现如下询问:

Are you sure you want to continue connecting (yes/no)?

键入yes后回车,如果出现

Hi xxx! You’ve successfully authenticated, but GitHub does not provide shell accessConnection to github.com closed.

 

那就是配置成功

 

原文地址:https://www.cnblogs.com/sunzhiqi/p/10862043.html