简体   繁体   English

从 WSL2 使用 SSH 时被提示输入“git@github.com”的密码

[英]Being prompted for the password for "git@github.com" when SSH-ing from WSL2

I recently upgraded to WSL2 on Windows 10 and followed the usual ssh keygen procedure with github, however for some reason git commands over ssh result in the following prompt:我最近在 Windows 10 上升级到 WSL2,并按照通常的 ssh 注册程序使用 github,但是由于某种原因,ssh 上的 git 命令导致以下提示:

git@github.com's password:

My checklist:我的清单:

  • ssh-agent is running ssh-agent正在运行
  • the correct private keys have been added via ssh-add已通过ssh-add了正确的私钥
  • the private keys have 600 permissions私钥有600权限
  • the correct public keys have been added to github正确的公钥已添加到 github

From my cursory research, it sounds like I might be having some credential propagation issue with Windows but I'm very unclear about what that might involve at this point.根据我的粗略研究,听起来我可能遇到了 Windows 的一些凭证传播问题,但我不清楚此时可能涉及什么。 I have generated and am hosting all my ssh keys in the linux subsystem so I don't think the above applies.我已经生成并将我所有的 ssh 密钥托管在 linux 子系统中,因此我认为以上内容不适用。

When running ssh -Tvvv git@github.com I can see the public keys being offered but not accepted:运行ssh -Tvvv git@github.com时,我可以看到提供但未被接受的公钥:

debug1: Offering public key: ...
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password

Any guidance would be appreciated!任何指导将不胜感激!

GitHub does not offer password authentication. GitHub 不提供密码验证。 It uses a dedicated service that doesn't even contain this as a possibility.它使用甚至不包含这种可能性的专用服务。 Thus, the machine you are connecting to is not GitHub and instead is an imposter.因此,您要连接的机器不是 GitHub,而是冒名顶替者。

You should remove the known keys for github.com with the following command:您应该使用以下命令删除github.com的已知密钥:

$ ssh-keygen -R github.com -f ~/.ssh/known_hosts

Then, try running ssh git@github.com and when you are prompted for the fingerprint, go to the documentation page where GitHub lists their fingerprints and verify that the fingerprint is correct.然后,尝试运行ssh git@github.com ,当系统提示您输入指纹时,go 到文档页面,其中 GitHub 列出了他们的指纹并验证指纹是否正确。 If it is not, then immediately stop and don't proceed.如果不是,则立即停止并且不要继续。 This is why it's essential that you check SSH host fingerprints from a trusted source out of band.这就是为什么您必须从带外可信来源检查 SSH 主机指纹的原因。

It is likely that you have some sort of SSH proxy on your.network or local machine, which could include some sort of antivirus, firewall, or monitoring software on your local machine, which is intercepting connections.您的网络或本地计算机上可能有某种 SSH 代理,其中可能包括某种防病毒软件、防火墙或本地计算机上的监控软件,它们正在拦截连接。 If it's a home.network, this could also be your router.如果是 home.network,这也可能是您的路由器。 You should fix that system not to intercept your data, or move to another.network.您应该修复该系统,使其不拦截您的数据,或转移到另一个网络。

Alternately, you may wish to try SSHing to ssh.github.com on port 443. To do so, you'd change your remote.或者,您可能希望尝试通过 SSH 连接到端口 443 上的 ssh.github.com。为此,您需要更改遥控器。 For example, if you're currently working with the GitHub repository git/git, then you'd do this: git remote set-url origin ssh://ssh.github.com:443/git/git.git .例如,如果您当前正在使用 GitHub 存储库 git/git,那么您可以这样做: git remote set-url origin ssh://ssh.github.com:443/git/git.git . That may allow you to bypass the.network device that's tampering with your connection.这可能允许您绕过正在篡改您的连接的网络设备。

You can follow this link to try https://docs.github.com/zh/authentication/troubleshooting-ssh/using-ssh-over-the-https-port您可以点击此链接尝试https://docs.github.com/zh/authentication/troubleshooting-ssh/using-ssh-over-the-https-port


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

2.Follow the documentation to add the following content to the config file,If there is no config, create a new one yourself.Just delete the suffix.Then enter the following: 2.按照文档在config文件中添加如下内容,如果没有config就自己新建一个。删除后缀即可。然后输入以下内容:

Host github.com主机 github.com

Hostname ssh.github.com主机名 ssh.github.com

Port 443端口 443

User git用户 git


3.try connect again 3.再次尝试连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM