设置git的user name 和 email
$ git config --global user.name "YOURNAME"
$ git config --global user.email "YOUREMAIL"
生成SSH
先看看是否存在~/.ssh 如果有则先备份删除
$ ssh-keygen -t rsa -C"描述信息"
接着按三个回车
最后在~/.ssh/ 底下会有有两个文件 id_rsa 和 id_rsa.pub
将.pub里的内容拷贝
在github网站的setting->ssh设置里 添加一个密钥,将刚刚拷贝的内容贴到这里面
回到控制台进行测试
$ssh -T git@github.com
The authenticity of host ‘github.com (207.97.227.239)’ can’t be established.
RSA key fingerprint is 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
Warning: Permanently added ‘github.com,207.97.227.239′ (RSA) to the list of known hosts.
ERROR: Hi tekkub! You’ve successfully authenticated, but GitHub does not provide shell access
Connection to github.com closed.
如果看到以上信息,就说明你的key已经成功链接
如果你在git clone 或者 git push的时候弹出类似 unable to access ' xxxx': Server aborted the SSL handshake 的错误 不妨 试试将url的源换一下,见:
https://help.github.com/articles/changing-a-remote-s-url/