-
打开 git Bash.
-
输入以下命令:(
your_email@example.com 为你注册git的邮箱地址
)$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
-
但有显示 "Enter a file in which to save the key," 请按 Enter 键 ,这样就使用默认的存储位置和名字
> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter] 最后得到了两个文件:id_rsa和id_rsa.pub, 这两个文件会保存在C:\Users\XX\.ssh (XX为当前登录电脑的用户名)
-
添加密钥到ssh ,执行:
ssh-add ~/.ssh/id_rsa
如果显示如下错误:
Could not open a connection to your authentication agent,则先执行如下命令即可:
ssh-agent bash
5. .在github上添加ssh密钥
这要添加的是“id_rsa.pub”里面的公钥,
打开https://github.com/ ,然后登录, 点击个人信息和设置-》 SSH 和GPG秘钥 -》管理 SSH 密钥-》添加
用记事本打开C:\Users\XX\.ssh\
id_rsa.pub 文件,将里面的所有内容复制粘贴
6. 测试:ssh -vvv git@githup.com
官网原话描述:
https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
说白了,信息需要和你客户端的信息一致: