当前位置: 首页 > news >正文

SSH配置过程及无法正常链接问题的解决【小白教学】

1.尝试克隆github上的项目,发现无法正常下载【之前有些是可以的】

git clone https://github.com/mogualla/PythonRobotics.git --depth 3

出现下面的提示【错误】:
Cloning into 'PythonRobotics'...
fatal: unable to access 'https://github.com/mogualla/PythonRobotics.git/': SSL certificate problem: unable to get local issuer certificate

2.生成密匙

ssh-keygen -t ed25519 -C "your_email@example.com"

显示:

Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\90534/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):【给密码】
Enter same passphrase again:【重复】

【成功】

Your identification has been saved in C:\Users\90534/.ssh/id_ed25519.
Your public key has been saved in C:\Users\90534/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:fTxHgkWTAxdKXST8+HX+xtMLStwz1eADPXNMjCqxDno a122479864@126.com
The key's randomart image is:
+--[ED25519 256]--+
|          o=B=oo.|
|         ..==+.o.|
|          ooo=* o|
|        ..o.o=.=+|
|       .So..+.++o|
|      . E o..oo..|
|       .   o = .o|
|          . . +.=|
|           .   oo|
+----[SHA256]-----+

3.配置公匙

打开并查看公匙文件:

cat ~/.ssh/id_ed25519.pub

 显示内容:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP6XxxxUA+vMJTEkNW28twwPyxxx8QDuf97eBaCMi3ik a1xxx4@126.com

复制后打开github:

4.配置环境

eval "$(ssh-agent -s)"

显示【失败】:【可能是电脑不支持使用环境配置】

unable to start ssh-agent service, error :1058
eval : 无法将“eval”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ eval "$(ssh-agent -s)"
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (eval:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

搜索:

右键以管理员身份打开【不然会报错】:

Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent

此时不用输 eval "$(ssh-agent -s)"

直接:

ssh-agent -s

这里网上说会显示一串东西,然后配环境变量,但我这里没显示,所以直接配密匙【记得中间改用户名】:

ssh-add C:\Users\用户\.ssh\id_ed25519

提示【完成】:

Enter passphrase for C:\Users\90534\.ssh\id_ed25519:【输入密码】
Identity added: C:\Users\90534\.ssh\id_ed25519 (axxx4@126.com)

5.测试连接

ssh -T git@github.com

显示【失败】:【可能是22被占用了】

ssh: connect to host github.com port 22: Connection refused

检查网络:

ping github.com

显示【成功】:

正在 Ping github.com [::1] 具有 32 字节的数据:
来自 ::1 的回复: 时间<1ms
来自 ::1 的回复: 时间<1ms
来自 ::1 的回复: 时间<1ms
来自 ::1 的回复: 时间<1ms

::1 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms

使用其他端口连接:

ssh -T -p 443 git@ssh.github.com

 显示【成功】:

The authenticity of host '[ssh.github.com]:443 ([20.200.243.160]:443)' 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 '[ssh.github.com]:443,[20.200.243.160]:443' (ECDSA) to the list of known hosts.
Hi mogualla! You've successfully authenticated, but GitHub does not provide shell access.【成功】

默认配置【避免在之后重复输入443】:

打开C:\Users\用户\.ssh文件夹:

新建无后缀的config:

用记事本打开后,在里面粘贴:

Host github.com
  Hostname ssh.github.com
  Port 443

保存后运行:

ssh -T git@ssh.github.com 

显示【成功】:

The authenticity of host 'ssh.github.com (20.200.243.160)' 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 'ssh.github.com,20.200.243.160' (ECDSA) to the list of known hosts.
Hi mogualla! You've successfully authenticated, but GitHub does not provide shell access.

6.验证

克隆【成功】:

git clone --recursive git@github.com:mogualla/PythonRobotics.git --depth 3  

Cloning into 'PythonRobotics'...
Enter passphrase for key '/c/Users/用户/.ssh/id_ed25519':【密码】
remote: Enumerating objects: 676, done.
remote: Counting objects: 100% (676/676), done.

完结撒花!!!

部分命令借鉴:如何生成SSH密钥_编译服务器生成ssh密钥的命令-CSDN博客

相关文章:

  • JVM类文件结构详解
  • 【计算机网络运输层详解】
  • OpenCV-Contrib常用扩展模块
  • Python模块化设计——递归
  • git push 提示 fatal: the remote end hung up unexpectedly
  • Linux系统管理与编程10:任务驱动综合应用zabbix-agent2
  • STM32滴答定时器(SysTick)原理及延时函数实现
  • python爬虫DrissionPage的使用
  • 【CC2530 教程 二】CC2530定时器实现微秒、毫秒、秒延时函数
  • 爬虫框架Scrapy从入门到实战
  • android初学
  • cython编译pyd并且c调用
  • 腾讯四面面经
  • Qt-Q_ENUM宏和QMetaEnum类
  • rocky linux 与centos系统的区别
  • 16.Linux蓝牙从硬件驱动到应用
  • HTTP核心知识
  • vue插槽传送和接收item
  • pyqt5报错:qt.qpa.plugin: Could not find the Qt platform plugin “xcb“(已解决)
  • Linux安装Ollama+MaxKB建立本地知识库
  • 墨西哥宣布就“墨西哥湾”更名一事起诉谷歌
  • 复旦发文缅怀文科杰出教授裘锡圭:曾提出治学需具备三种精神
  • 人民日报评“组团退演出服”:市场经济诚信原则需全社会维护
  • 最快3天开通一条定制公交线路!上海推出服务平台更快响应市民需求
  • 视频丨习近平同普京会谈:共同弘扬正确二战史观,维护联合国权威和地位
  • 北上广深均宣布下调个人住房公积金贷款利率