Windows下生成GitHub/Gitee SSH key

前提:已安装git。

1、输入以下命令生成ssh key,一路回车即可。(xxxx@xxx.com为你注册GitHub的邮箱)(注意,Gitee只需这一步,然后复制密码就好)

GitHub:ssh-keygen -t rsa -C "xxxx@xxx.com"

Gitee:ssh-keygen -t ed25519 -C "xxxx@xxx.com"

复制代码
$ ssh-keygen -t rsa -C  "xxxx@xxx.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:/ydX+AEdhH+HOukbM2knJNHjaa+vPhctxE70hDJv4ys  "xxxx@xxx.com"
The key's randomart image is:
+---[RSA 3072]----+
|              oo |
|           .o.o..|
|          . o*o+.|
|           o +Oo+|
|        S . =O.+o|
|         . ++o*.o|
|          ..B.o*.|
|           oEB= .|
|           .*@.  |
+----[SHA256]-----+
复制代码

2、输入命令:eval "ssh-agent -s"

$ eval "ssh-agent -s"
SSH_AUTH_SOCK=/tmp/ssh-pdrfl8Q4DvbK/agent.585; export SSH_AUTH_SOCK;
SSH_AGENT_PID=586; export SSH_AGENT_PID;
echo Agent pid 586;

3、继续输入命令:ssh-add ~/.ssh/id_rsa

$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Administrator/.ssh/id_rsa (xxxx@xxx.com)

如果报错(Could not open a connection to your authentication agent.),则需要先执行命令:ssh-agent bash,再执行上述命令

 

4、复制生成的key到GitHub

查看key:cat ~/.ssh/id_rsa.pub(Gitee:$ cat .ssh/id_ed25519.pub)

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCbLVIplXKxgdi2fi2ZhPW6o5dtF/mSeE3CmlFxmfUDoDgPaQDqebEiOaBNBN1GYvcpQxLXTkRuA9g7nf8DnH3qKfUq98QftsxbAcwvH1Xr0EcJFakMx7d0pGFH1RQ/kVr1iU3kKU4wuKhQn73Momje18BormKovP5InObSWNu7TAtkhmgF43W31NJjqS+mJ9v62Y7r65uetUgRwv9+MGJP3CO62TTLjdIom8VpK5uch7EGm3x6FYt8VT3urZS/ji/ixlvKaRJ7X1MJrCbQQ+8EfHejpKhQxZ0HU3p8CIjdbL1d9j1wIc8kz11zrEaoNSPdwK9J8pnl2o+TjoNQIUvNd0JHDsosCZARB0tzmuS0WnA3VvoldcIsMBfGC52bKW/zWuKkSUS0j+BTDvyk3aaS//ITmCnwffQeBo8C3A59KY00bEGDAWjhWhxJvQAhw3Qum7bZTIrC/glhwSxOcFSSEh0gu9hLLLQ2iq5CiNfbNv8/JpTPIDp/G+irUQ7URrE= "xxxx@xxx.com"

GitHub位置如下:

 

 

 

5、检查是否成功:

ssh -T "git@github.com" (Gitee:ssh -T git@gitee.com)

复制代码
GitHub的连不上,Gitee倒是连上了

$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (212.64.63.215)' can't be established.
ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
Hi mikasama! You've successfully authenticated, but GITEE.COM does not provide shell access.

复制代码
 

posted on   Mikasama  阅读(730)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示