这篇博文介绍了如何配置git密钥,并在github使用git密钥来进行远程连接鉴权。
git下载
git配置
1 | git config --global user.name "你的GitHub用户名" |
生成密钥
1 | ssh-keygen -t rsa -b 4096 -C "你的GitHub注册邮箱" |
github密钥管理
github密钥管理直达链接
1)New SSH Key,复制本地 ~/.ssh(window下为 C:\User\用户.ssh)的 id_rsa.pub
2)Title为标题,任意填即可,将刚刚复制的id_rsa.pub内容粘贴进去
3)最后点击Add SSH key。
检验
在Git Bash中检测GitHub公钥设置是否成功,输入ssh -T git@github.com
为不同网站应用各自的 SSH KEY
编辑ssh配置 vim ~/.ssh/config
追加以下内容1
2
3
4
5
6
7
8
9Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_a
Host git.oschina.net
HostName git.oschina.net
User git
IdentityFile ~/.ssh/id_rsa_b