流浪のwolf

卷帝

导航

< 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

统计

ssh建立github连接 基于ssh密钥

1. 建立公钥和私钥

ps:公钥放在github上面的,私钥放在自己本地电脑 ;

先生成密钥:打开 gitbash 输入命令:

ssh-keygen -t rsa -b 4096 -C "zhulongxu2022@163.com"

中间会让你输入东西不用管,直接一直回车 ;

结果:

复制代码
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/zhulo/.ssh/id_rsa):
Created directory '/c/Users/zhulo/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/zhulo/.ssh/id_rsa
Your public key has been saved in /c/Users/zhulo/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:zrhuxX/87PmZODzZq1lGIn7TTq1Fqzh0v4IlcAscftI zhulongxu2022@163.com
The key's randomart image is:
+---[RSA 4096]----+
|                 |
|         .       |
|        o o      |
|         * E     |
|       .S *... ..|
|       +o .+.o+.o|
|      ..o..o*o+*o|
|      ..  .o=BX*o|
|     oo    o.B@B+|
+----[SHA256]-----+
复制代码

有如上代码表示成功;

结果就是生成了密钥并保存在  C:\Users\zhulo\.ssh 里面 ;

 

2. 将SSH密钥添加到ssh-agent

输入 eval 回车 

输入 ssh-agent -s 回车 

 

 3. 把ssh添加到账户

输入 ssh-agent bash 

输入 ssh-add ~/.ssh/id_rsa 

如下结果出现则说明成功 ;

 

 4. 把公钥复制到github上面 

使用命令 cat ~/.ssh/id_rsa.pub 

 

 把这段文字复制到github的新增密钥上面保存即可 ;

终端输入:ssh -T git@github.com 

显示:

The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

选择  yes 回车 显示如下;

Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
Hi xxxxxx You've successfully authenticated, but GitHub does not provide shell access.

ps:如果 xxxxx 如果是你的 github 账号名说明ssh建立成功 ;

 

posted on   朱龙旭的网络  阅读(91)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· 支付宝 IoT 设备入门宝典(下)设备经营篇
· 万字调研——AI生成内容检测
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
点击右上角即可分享
微信分享提示