Windows下生成GitHub/Gitee SSH key
2022/6/26 5:21:49
本文主要是介绍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.
这篇关于Windows下生成GitHub/Gitee SSH key的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南
- 2024-11-23JAVA项目部署入门:新手必读指南
- 2024-11-23Java项目部署入门:新手必看指南
- 2024-11-23Java项目部署入门:新手必读指南
- 2024-11-23Java项目开发入门:新手必读指南
- 2024-11-23JAVA项目开发入门:从零开始的实用教程
- 2024-11-23Java项目开发入门:新手必读指南