一 关于SSH
使用SSH协议,可以连接和验证远程服务器和服务。用SSH密钥,可以不需要每次访问GitHub时提供用户名和密码。在将代码上传到GitHub时,就需要用SSH
二 检查是否存在SSH keys
$ ls -al ~/.ssh
检查是否存在以 .pub
结尾的文件,一般来说文件名是以下之一:id_das.pub
, id_ecdsa.pub
, id_ed25519.pub
, id_rsa.pub
。如果存在,说明之前已经创建了SSH keys,跳过第三步
三 生成一个新的SSH key
1.your_email@example.com
替换为自己的GiHub邮箱地址
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
2.后面一直回车
Generating public/private rsa key pair.
Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
四 将SSH key 加入到Github账户中
- 4.
$ cat ~/.ssh/id_rsa.pub
copy your publish SSH key
5.
6.
Reference
https://help.github.com/articles/connecting-to-github-with-ssh/