linux$ git config --global user.name "humingx" $ git config --global user.email "humingx@yeah.net"
linux$ ssh-keygen -t rsa -C "humingx@yeah.net"
连续3个回车。若是不须要密码的话。
最后获得了两个文件:id_rsa
和id_rsa.pub
。linux
若是不是第一次,就选择overwrite
.git
确保 ssh-agent 是可用的。ssh-agent是一种控制用来保存公钥身份验证所使用的私钥的程序,其实ssh-agent就是一个密钥管理器,运行ssh-agent之后,使用ssh-add将私钥交给ssh-agent保管,其余程序须要身份验证的时候能够将验证申请交给ssh-agent来完成整个认证过程。github
linux# start the ssh-agent in the background eval "$(ssh-agent -s)" Agent pid 59566
添加生成的 SSH key 到 ssh-agent。shell
linux$ ssh-add ~/.ssh/id_rsa
把id_rsa.pub
文件里的内容复制到这里ssh
linux$ ssh -T git@github.com
你将会看到:ide
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
测试
Hi humingx! You've successfully authenticated, but GitHub does not provide shell access.
若是看到Hi
后面是你的用户名,就说明成功了。fetch
.git
文件夹下config
中的url
。修改前加密
[remote "origin"] url = https://github.com/humingx/humingx.github.io.git fetch = +refs/heads/*:refs/remotes/origin/*
修改后url
[remote "origin"] url = git@github.com:humingx/humingx.github.io.git fetch = +refs/heads/*:refs/remotes/origin/*