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密钥的命令-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值