一、 安装好Git了之后,设置Git的连接:
第一次使用没有SSH目录,先创建一个新的SSH KEY ,打开Mac的终端输入:
$ ssh-keygen -t rsa -C "github账号的邮箱" 1.注意C是大写的 2.记得输入你的github账号的邮箱 ,回车3.会输出下面
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/susonglin/.ssh/id_rsa): //这里直接按enter(回车键)
二、按下enter(回车)之后会出现以下代码提示
Enter passphrase (empty for no passphrase):
//提示你输入密码(不管直接按回车,不输入则是空的啦)
Enter same passphrase again:
//提示你重新输入以便确认输入是否正确(还是不管直接回车)
随后会提示一大串我看不懂的,反正大概意思就是你创建好了 id_rsa 和 id_rsa.pub 文件。
接下来就要找** id_rsa.pub**文件
$ open ~/.ssh
即可,打开文件夹(弹出来),就可以找到id_rsa.pub文件了。
然后用Sublime编译器打开(为在 Github 上添加你的 SSH KEY 做铺垫) ,如下图
![](https://img.haomeiwen.com/i7263959/79c181b257a8e3e0.png)
按下回车键
![](https://img.haomeiwen.com/i7263959/737ec3a3117abd21.png)
三、在 Github 上添加你的 SSH KEY
1.登陆github,点Your
![](https://img.haomeiwen.com/i7263959/6a1337d26217399b.png)
![](https://img.haomeiwen.com/i7263959/fc22ec9333651e46.png)
3.点击SSH and GPG keys
![](https://img.haomeiwen.com/i7263959/b11a9cc8730ccae7.png)
4.点SSH kys 右边的New SSH key(创建SSH
![](https://img.haomeiwen.com/i7263959/394f40d5fcd4af2d.png)
5.好了之后会出现这样如图下
![](https://img.haomeiwen.com/i7263959/b0a5a6d4ad6bee30.png)
四、验证你的Github连接
在终端输入
$ ssh -T git@github.com
出现以下代码
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
输入yes后,会显示出以下代码(表示成功了)
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
网友评论