git BitBucket:主机密钥验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40576718/
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
BitBucket: Host key verification failed
提问by CrazySynthax
I want to clone a remote repository to my local machine. I used the command:
我想将远程存储库克隆到我的本地计算机。我使用了命令:
git clone [email protected]:<username>/<repo_name>.git
and I got the message:
我得到了消息:
The authenticity of host 'bitbucket.org (104.192.143.3)' can't be
established. RSA key fingerprint is
SHA256:****. Are you sure you
want to continue connecting (yes/no)? Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
I just want to mention that I already took care of the ssh issues. I generated an ssh key by the command 'ssh-keygen
' and I copied the contents of ~/.ssh/id_rsa.pub
to Bitbucket Settings -> SSH keys
(according to this link: https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html)
我只想提一下,我已经解决了 ssh 问题。我通过命令 ' ssh-keygen
'生成了一个 ssh 密钥,并将其内容复制~/.ssh/id_rsa.pub
到Bitbucket Settings -> SSH keys
(根据此链接:https: //confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html)
I also looked at my "user and group access" and I saw this:
我还查看了我的“用户和组访问”,我看到了这一点:
Can you advise me what to do?
你能告诉我该怎么做吗?
回答by Jakuje
The message says
消息说
Host key verification failed.
主机密钥验证失败。
nothing about authentication, so you are working on the wrong field. It means that the host key of the bitbucket.orgis not in your ~/.ssh/known_hosts
and your client does not have any way how to verify it. It was answered many timeshow to workaround it, but how to do it properly?
与身份验证无关,因此您在错误的领域工作。这意味着bitbucket.org的主机密钥不在您的手中~/.ssh/known_hosts
,您的客户端没有任何方法可以验证它。多次回答如何解决它,但如何正确地做到这一点?
There is sectionin the bitbucket manuals, describing how their public keys and fingerprint looks like. So:
bitbucket 手册中有一节描述了他们的公钥和指纹的样子。所以:
- Run
ssh bitbucket.org
It will prompt you with one of the fingerprints:
The authenticity of host 'bitbucket.org (104.192.143.3)' can't be established. RSA key fingerprint is SHA256:*****. Are you sure you want to continue connecting (yes/no)?
You verify the fingerprint in the prompt is the same as on the bitbucket website:
SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A bitbucket.org (RSA)
You write
yes
and press enter to verify the connection works.
- 跑
ssh bitbucket.org
它会提示您输入其中一个指纹:
The authenticity of host 'bitbucket.org (104.192.143.3)' can't be established. RSA key fingerprint is SHA256:*****. Are you sure you want to continue connecting (yes/no)?
您验证提示中的指纹与bitbucket 网站上的指纹相同:
SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A bitbucket.org (RSA)
您编写
yes
并按 Enter 以验证连接是否正常。
Or just copy the public key from the bitbucket websitedirectly in the ~/.ssh/known_hosts
file
或者直接从bitbucket网站复制公钥到~/.ssh/known_hosts
文件中
echo "bitbucket.org,104.192.143.1 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==" >> ~/.ssh/known_hosts
if nothing from the above helps, please run ssh -vvv bitbucket.org
and post the output to the edited question.
如果以上没有任何帮助,请运行ssh -vvv bitbucket.org
并将输出发布到已编辑的问题。
回答by NickUnuchek
mkdir ~/.ssh
touch ~/.ssh/known_hosts
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts