1.使用ssh-keygen命令生成key pair:
--------------------------------------------------------------------------------
$ssh-keygen -t rsa -C "YourEmail" # "-t rsa"表示使用密钥的加密类型,还可以为dsa;-C设置注释文字,比如你的邮箱“YourEmail”,不一定要是github注册邮箱Enter file in which to save the key (/Users/faner/.ssh/id_rsa): # 直接回车
Enter passphrase (empty for no passphrase): # 输入密钥文件授权密码
Enter same passphrase again: # 确认密钥文件授权密码
Your identification has been saved in /Users/faner/.ssh/id_rsa.
Your public key has been saved in /Users/faner/.ssh/id_rsa.pub.
2.在github上为当前账号添加SSH公钥:
(1)这里Add SSH Key相当于注册到SSH服务器(github.com)的受信任列表(authorized_keys)中。
(2)SSH服务器受信任列表(authorized_keys)中可以添加多个SSH客户端的公钥,其中title用于做简单识别,真正起识别作用的是公钥指纹(RSA key fingerprint)。
(3)向SSH服务器(github.com)Add自己的SSH Public Key后,github.com将这个SSH Key与你的github账号关联起来,你的机器(Mac git client)将有写权限向你github账号名下的remote repository进行push提交代码。
原博客地址 http://blog.csdn.net/phunxm/article/details/45083335 谢谢