Mac下一般都自带安装了git,在这就不继续说如何安装git了.
检查是否存在ssh keys
如果显示No such file or directory,则直接跳到第三步去
如果存在.ssh目录,请先备份好你的ssh keys
1 2 3
| mkdir ssh_key_backup cp id_rsa* ssh_key_backup rm id_rsa*
|
生成一个新的ssh keys
1 2 3 4
| $ ssh-keygen -t rsa -C “your_email@example.com” Generating public/private rsa key pair. Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
|
1 2
| Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]
|
1 2 3
| Your identification has been saved in /Users/you/.ssh/id_rsa. Your public key has been saved in /Users/you/.ssh/id_rsa.pub. The key fingerprint is:01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
|
说明已生成成功,在 ./ssh 目录下面会多出 id_rsa 和 id_rsa.pub 这两个文件
在GitHub网站上添加你的ssh keys
- 找到刚才生成的 id_rsa.pub,复制里面的内容
- 打开 GitHub 网站并登录,找到 “Account Settings”,点击 “SSH Keys”,然后”Add SSH key”, 把刚才id_rsa.pub里面的内容粘贴进去就可以了
然后有又一堆提示,输入yes就可以了
最后验证成功的话,会出现类似下面的提示
1
| Hi username! You've successfully authenticated, but GitHub does not provide shell access.
|
大功告成..!
少年觉得如何?简单吧,使劲的折腾吧..!
####参考资料