git 无法建立主机的真实性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11443687/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:06:00  来源:igfitidea点击:

The authenticity of host can't be established

gitssh

提问by styler

I am doing a git pull for the first time and have been prompted in git that the authenticity of host can't be established, the RSA key fingerprint isn't correct compared to the private key I generated. I was just wondering how I can update this so it reads the correct file and why does it read the wrong fingerprint in the first place?

我是第一次做git pull,在git中被提示无法建立主机的真实性,RSA密钥指纹与我生成的私钥相比不正确。我只是想知道如何更新它以便它读取正确的文件以及为什么它首先读取错误的指纹?

回答by vijay

I had similar issue, which means that the remote host is unknown /untrusted. The fix is to have the remote host entry in the known_hosts file.

我有类似的问题,这意味着远程主机未知/不受信任。修复方法是在 known_hosts 文件中包含远程主机条目。

This is what I have done:

这就是我所做的:

  1. Generate (or use existing) RSA keys and store them in the <USER.HOME>/.sshfile. If you are using eclipse, you can generate RSA keys using Preferences;

    • General -> Network Connections -> SSH2 and then select the Key Management.
    • Now Click Generate RSA Key...
    • And then Save Private Key...in the .ssh folder
  2. Now your <USER.HOME>/.sshwould contain file; private key, public key and known_hosts

  3. share your public key with your trusted hosts.
  4. Open Git Bash Promp (command prompt) and enter below command.
  5. When it prompts error ... Are you sure you want to continue connecting (yes/no)?
  6. Say 'yes'
  7. Now your remote host is added to the known_hosts
  8. Done.
  1. 生成(或使用现有的)RSA 密钥并将它们存储在<USER.HOME>/.ssh文件中。如果您使用的是 eclipse,则可以使用 Preferences 生成 RSA 密钥;

    • General -> Network Connections -> SSH2 然后选择 Key Management。
    • 现在点击 Generate RSA Key...
    • 然后Save Private Key...在 .ssh 文件夹中
  2. 现在您<USER.HOME>/.ssh将包含文件;私钥、公钥和known_hosts

  3. 与您信任的主机共享您的公钥。
  4. 打开 Git Bash Promp(命令提示符)并输入以下命令。
  5. 当它提示错误时...您确定要继续连接吗(是/否)?
  6. 说“是”
  7. 现在您的远程主机已添加到 known_hosts
  8. 完毕。

Now if you try pushing the file to remote, you don't see any errors.

现在,如果您尝试将文件推送到远程,则不会看到任何错误。

回答by JD Frias

Another problem I ran into was multiple entries in the known_hostsfile as well as a known_hosts2file.

我遇到的另一个问题是known_hosts文件中的多个条目以及一个known_hosts2文件。

My only guess is that since I reused a host name in ./ssh/configto point to different IPs it got confused an created multiple entries.

我唯一的猜测是,由于我重用了一个主机名./ssh/config来指向不同的 IP,它混淆了创建的多个条目。

回答by RayLoveless

There is a better answer posted here:

这里发布了一个更好的答案:

http://stackoverflow.com/questions/2643502/git-permission-denied-publickey

http://stackoverflow.com/questions/2643502/git-permission-denied-publickey

This saved me!!!

这救了我!!!

These commands only work in the git bash prompt. For windows you most likely will need to be in your c:/users//.ssh directory. and also name your key "is_rsa". passphrase is optional and if you provide on you'll be prompted for it each time you do a pull.

这些命令仅适用于 git bash 提示符。对于 Windows,您很可能需要在 c:/users//.ssh 目录中。并将您的密钥命名为“is_rsa”。密码是可选的,如果您提供了密码,则每次执行拉取时都会提示您输入密码。

good luck.

祝你好运。