简体   繁体   中英

Git server's host key not cached in registry - GitHub.com

Continuation of issue here : I'm trying to set up my first Git Repository on GitHub. (Note, this means I can't use putty, I'm using openssh, or at least I'm supposed to and I think I am). I've been following the documentation on GitHub's website here . I get everything right up until the very last command: git push -u origin master . It gives me the following error:

The server's host key is not cached in the registry.
You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is: ssh-rsa 2048
16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Connection abandoned. fatal: The remote end hung up unexpectedly

I'm guessing this means that in my known_hosts file their ssh-rsa key isn't found, but I'm not sure how to fix that. I've tried ssh -T git@github.com and I log on just fine. I've also tried closing the git bash and re-opening in case it's a cache issue. This doesn't fix the problem. This is the only output I get that differs from what the documentation indicates. I'm hoping to put up a sweet Java Helper Library, so any help would be greatly appreciated!

使用带有指向 plink.exe 的 GIT_SSH 的 git-for-windows,向服务器打开一个腻子并接受主机密钥(然后终止腻子会话,甚至不继续登录)足以为我解决这个问题。

On Windows, it seems that sometimes you don't get to actually accept a server's host key.

Try one of the following commands from the Power Shell:

ssh github.com

Or

plink.exe -agent github.com

Run these standalone and press y when asked to accept the host key.

Use ssh-add to add your private key to the current Power Shell session:

C:> ssh-add PATH\TO\PRIVATE\KEY

Afterwards, you should be able to successfully run git push .

Source: http://help.github.com/ssh-issues/

The ideal solution would be (if you really don't need to use plink in git) removing the GIT_SSH environment variable and generating a new keypair with command ssh-keygen -t rsa -C "youremail" on Git Bash then change your ssh key in github because from what I've understood from the comments is putty and openssh is conflicting.

However, if you still want to use plink you can use PuTTYgen to generate a PuTTY format key then change your public key in github and load your private key in PuTTYagent then you should do a connect to github.com with PuTTY this would add githubs fingerprint to known_hosts and you are good to go. This would be a resource to github with PuTTY http://nathanj.github.com/gitguide/tour.html

Adding info to the post of @Name (for the sake of completeness), as I just had (again) this issue today.

Putty stores its SSH known hosts in a registry key , not in the ~/.ssh/known_hosts file like SSH. So to make Git work with PLink and Pagent, you just have to start a Putty session on the remote Git server, and accept the key. This way, you won't have the message again.

This is disturbing, as you have to accept the SSH key twice : one for SSH-ing the server, one for Putty/Plink/Pagent, but once you do it, it works like a charm.

This worked for me:

I verified the github fingerprint here: https://help.github.com/en/github/authenticating-to-github/githubs-ssh-key-fingerprints

Once confimed, git didn't asked again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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