BitBucket:主机密钥身份验证失败

时间:2016-11-13 17:27:34

标签: git ssh bitbucket

我想将远程存储库克隆到本地计算机。我用了命令:

git clone git@bitbucket.org:<username>/<repo_name>.git

我收到了消息:

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.

我只想提一下我已经处理了ssh问题。我通过命令&#39; ssh-keygen&#39;生成了一个ssh密钥。我将~/.ssh/id_rsa.pub的内容复制到Bitbucket Settings -> SSH keys(根据此链接:https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

我还查看了我的&#34;用户和群组访问权限&#34;我看到了这个:

enter image description here

你可以告诉我该怎么办?

3 个答案:

答案 0 :(得分:28)

消息说

  

主机密钥验证失败。

没有关于身份验证,所以你正在处理错误的字段。这意味着bitbucket.org的主机密钥不在您的~/.ssh/known_hosts中,并且您的客户端无法如何验证它。 It was answered many times如何解决问题,但如何正确处理?

bitbucket手册中有section,描述了他们的公钥和指纹的样子。所以:

  1. 运行ssh bitbucket.org
  2. 它会提示您一个指纹:

    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)?
    
  3. 您确认提示中的指纹与bitbucket website上的指纹相同:

    SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A bitbucket.org (RSA)
    
  4. 您编写yes并按Enter确认连接有效。

  5. 或者直接从~/.ssh/known_hosts文件

    中的bitbucket website复制公钥
    echo "bitbucket.org,104.192.143.1 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==" >> ~/.ssh/known_hosts
    

    如果上述内容无效,请运行ssh -vvv bitbucket.org并将输出发布到已修改的问题。

答案 1 :(得分:2)

mkdir ~/.ssh
touch ~/.ssh/known_hosts
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts

答案 2 :(得分:0)

  • 如果文件不存在,则在 known_hosts 内创建一个名为 ~/.ssh 的文件。

  • 将以下内容粘贴到其中即可。

    bitbucket.org,104.192.143.1 SSH-RSA AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl / VqLat / MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy + YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK + dc8KZJZWYjAuORU3jc1c / NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO + mN2t / FZTMZLiFqPWc / ALSqnMnnhwrNi2rbfg / RD / IpL8Le3pSBne8 + seeFVBoGqzHM9yXw ==