第一:检查.ssh是否存在(ls -al ~/.ssh)

$ ls -al ~/.ssh
Lists the files in your .ssh directory, if they exist

第二:产生新的SSH key(ssh-keygen -t rsa -C "your_email@example.com")

$ ssh-keygen -t rsa -C "your_email@example.com"
Creates a new ssh key, using the provided email as a label
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase][Press enter]
Enter same passphrase again: [Type passphrase again][Press enter]
产生的结果如下:
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/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 添加新的key到ssh-agent:
$ ssh-agent -s
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa 如果出现Could not open a connection to your authentication agent
解决办法:
$ eval $(ssh-agent)
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
Identity added:/c/Users/you/.ssh/id_rsa(/c/Users/you/.ssh/id_rsa) 

第三:添加ssh key到github中

$ clip < ~/.ssh/id_rsa.pub
Copies the contents of the id_rsa.pub file to your clipboard
如下图所示:

第四:检查如否配置成功

在Git Bash中输入:

$ ssh -T git@github.com
Attempts to ssh to github

或许会出现:

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 username! You've successfully authenticated, but GitHub does not
provide shell access.

第五:改变git的remote url:将https://github.com/xxxx.git改成git@github.com:xxxx.git

即修改.git/config文件

文章摘自:https://help.github.com/articles/generating-ssh-keys

最新文章

  1. 【网络编程/C++】修改本机ip地址
  2. [WPF实用技巧]如何使WPF的TreeView节点之间有连线
  3. devices-list
  4. RFS一些基本概念
  5. 【freemaker】之eclipse安装freemaker-IDE
  6. Tomcat部署web应用的方式
  7. dom4j api 详解--XPath 节点详解
  8. linux搭建java环境
  9. Bower使用教程(限window)
  10. Mybatis-Oralce批量插入方法
  11. MySQL——修改用户密码 | 移除权限
  12. [django]http请求
  13. [剑指Offer]23-链表中环的入口节点
  14. 远程桌面连接 [Content] 出现身份验证错误。 要求的函数不受支持
  15. Intellij IDEA中file size exceeds configured limit解决
  16. alter修改表
  17. css实现div两列布局——左侧宽度固定,右侧宽度自适应(两种方法)
  18. python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
  19. myeclipse如何取消对某个文件的验证
  20. 【bzoj1782】[Usaco2010 Feb]slowdown 慢慢游 树链剖分+线段树

热门文章

  1. C#学习笔记(一)
  2. RCC 2014 Warmup (Div. 2) ABC
  3. codeforces #313 div1 E
  4. FocusWriter
  5. JS动态特性
  6. 散列表 (Hash table,也叫哈希表)
  7. 【转】android资源目录---assets与res/raw区别
  8. github上如何合并别人的pull request
  9. ogg实现oracle到sql server 2005的同步
  10. python 中@property的使用