github配置了ssh公钥后仍然无法git连接

问题遇到的现象和发生背景

很久没有用过git和github了,今天打算从网上拉一些东西发生报错。重新生成了公钥并在github上删除原公钥重新配置了,发现再次登录需要密码,而且不是我的github账号密码。

遇到的现象和发生背景,请写出第一个错误信息

当我按照网上的教程重新配置ssh公钥后用“ssh -T mailto:git@github.com”命令进行测试时,弹出的信息为“The authenticity of host 'github.com (::1)' can't be established.
ECDSA key fingerprint is SHA256:(密钥)”【按照教程来看这里的ECDSA应该是RSA】,随后要求我输入密码,我尝试输入github的账户密码,一直报错。

用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
$ ssh -T git@github.com
The authenticity of host 'github.com (::1)' can't be established.
ECDSA key fingerprint is SHA256:(密钥)
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ECDSA) to the list of known hosts.

                            ****USAGE WARNING****

This is a private computer system. This computer system, including all
related equipment, networks, and network devices (specifically including
Internet access) are provided only for authorized use. This computer system
may be monitored for all lawful purposes, including to ensure that its use
is authorized, for management of the system, to facilitate protection against
unauthorized access, and to verify security procedures, survivability, and
operational security. Monitoring includes active attacks by authorized entities
to test or verify the security of this system. During monitoring, information
may be examined, recorded, copied and used for authorized purposes. All
information, including personal information, placed or sent over this system
may be monitored.

Use of this computer system, authorized or unauthorized, constitutes consent
to monitoring of this system. Unauthorized use may subject you to criminal
prosecution. Evidence of unauthorized use collected during monitoring may be
used for administrative, criminal, or other adverse action. Use of this system
constitutes consent to monitoring for these purposes.


git@github.com's password:
(随后无论输入什么都无法访问)

运行结果及详细报错内容

如上所示,即使输入正确的github账户密码也无法进行访问。

我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%

我最后参考的教程是按照这个进行的:https://www.cnblogs.com/wanna2leo/p/16503723.html
比较奇怪的点是我加密方式是rsa,但是提示貌似表示我采用的是ECDSA加密的。无论我多少次重新生成ssh公钥并在github上重置,均告失败。【看见网上说不同的打开.pub文件可能导致内容不同,但是无论我采用记事本、vscode还是命令行cat方式打开,均告失败】

我想要达到的结果,如果你需要快速回答,请尝试 “付费悬赏”

我2022年初时配置ssh公钥过程相当顺利,不知道这次出什么问题了。希望我能够正常使用ssh公钥进行无密码访问。

自己解决了,不用麻烦后来人了。如果有后来者遇到一样的问题,请尝试"ssh -T -p 443 git@ssh.github.com"能否连接上,如果能,请参考:
https://blog.csdn.net/yuzhiqiang_1993/article/details/127032178

我们在日常或工作中使用Git的时候,可能需要在自己的电脑上同时使用Github和Gitee。方便我们向任意向两个代码托管平台来推送或者拉取操作代码。两个不用一个平台配置一个或者多个SSH公钥。

一、Github和Gitee的账号不一样

我们需要给Github和Gitee分别配置各自的SSH公钥

我们在配置SSH公钥的时候,往往都加上自己的邮箱地址或者说账号地址。这样就相当于将SSH公钥和账号给绑定在一起。

根据两个平台的邮箱地址,分别在Git Bash窗口里输入指令:

ssh-keygen -t rsa -C “xxxxxx@xxxxxx.com” # 双引号里填写平台的注册邮箱

生成SSH公钥,登录到对应的Github或者Gitee网站,再添加配置到账号中。这样就实现了一个公钥绑定一个账号。

二、Github和Gitee的账号一样

我们在生成SSH公钥时不添加后面的邮箱或者账号地址,直接在Git Bash窗口里输入指令:

ssh-keygen

这种指令生成的SSH公钥因为没有绑定账号邮箱,可以同时配置到Github或Gitee的账号中。这样就实现了一个SSH公钥让两个平台账号共用。

github可以支持ssh方式 也可以支持https方式 一种行不通的时候 或许可以尝试用另一种

github在国外,不好访问。