【转】在 github 添加一个 SSH key
参考:https://zhuanlan.zhihu.com/p/34584694
1、登录到 https://github.com ,在 设置 页面的左侧菜单里找到 SSH and GPG keys
2、打开 Git Bash
3、运行 ssh-keygen -t rsa -b 4096 -C "你的邮箱"
,注意要填写与 github.com 里相同的邮箱,不需要接收验证码啥的
4、按回车三次,就成功生成了一个 key,参考下图:
5、运行 cat ~/.ssh/id_rsa.pub
,得到一串东西,完整的复制这串东西
6、回到第1步的页面,点右侧的 New SSH key ,进入下图页面
6.1、 Title 随便填,比如 test ,Key type 不用改,Key 里粘贴刚复制的字符串
7、点击 Add SSH key 按钮后,页面会提示添加成功
8、回到 Git Bash ,敲这串命令 ssh -T git@github.com
8.1、 如果你看到 Permission denied (publickey).
就说明你失败了,需要重来;如果你看到 Hi FrankFang! You've successfully authenticated, but GitHub does not provide shell access.
就是成功了,如下图:
这两天清理磁盘后,发现 git 出问题了,报错:
fatal: unable to access 'https://github.com/linxxx.git/': SSL certificate problem: unable to get local issuer certificate
敲这两个命令后恢复正常:
ssh -T git@github.com git config --global http.sslVerify "false"