账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    git push 提示 Host key verification failed.
    29
    0

    环境

    • w10
    • vscode
    • git
    • tortoisegit

    问题描述

    • 当我使用 tortoisegit 进行 push 操作时,一切正常
    • 当我使用 vscode 进行 push 操作时,提示如下错误
    > git push origin master:master
    Host key verification failed.
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    • 是同一个项目,用 tortoisegit 配置了PPK密钥
    • github 配置了本机的ssh密钥

    希望大佬指点一下,十分感谢

    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 共 0 条
    • The "Host key verification failed" error message in Git can occur when the server you are pushing to does not accept the public key of the repository you are pushing to. This can happen when the server is configured to use a specific authentication method (such as SSH or HTTPS) and the public key provided by the repository is not valid or the private key is not properly configured.

      Here are some steps you can take to resolve this issue:

      1. Verify the repository's public key:
      2. Check the URL of the repository's public key file on GitHub, GitLab, or Bitbucket. This file is typically located in the .ssh/authorized_keys directory of the repository. Look for the key with the .pub extension, like git@github.com/user/repo.git.
      3. Double-check the key's authenticity by running the following command in your terminal: ssh -i <repository_key_file.pub> git@github.com:user/repo.git
      4. If the output of the command shows the public key is valid and does not contain any unauthorized characters, then the key is properly configured and can be pushed to the repository.

      5. If the public key is invalid or has unauthorized characters, you can regenerate the key:

      6. If the public key is valid but contains unauthorized characters, you can regenerate the key using the following command: ssh-keygen -t rsa -b 4096 -C "user@example.com"
      7. This command generates a new RSA private key with a 4096-bit key size and adds the specified email address as the public key's recipient.
      8. After the key generation process is complete, replace the old public key with the new one: git mv <repository_key_file.pub> <repository_key_file_new.pub>
      9. Then, run the command again to push the updated public key: git push -u origin master
      10. If the error message is still present, try running the command with the -d option to detach the local repository and generate a new one with the updated key: git push -d origin master
      11. This command creates a new detached repository and prompts you to select the public key from the .ssh/authorized_keys directory of the local repository.

      12. Verify the repository's private key:

      13. If the private key is not present, you can generate a new one by running the following command: ssh-keygen -t rsa -b 4096 -C "user@example.com"
      14. Follow the same steps as step 2 to regenerate the private key.
      15. After the key generation process is complete, replace the old private key with the new one: git mv <repository_key_file_new.pub> <repository_key_file_old.pub>
      16. Then, run the command again to push the updated private key: git push -u origin master
      17. If the error message is still present, try running the command with the -d option to detach the local repository and generate a new one with the updated key: git push -d origin master
      18. This command creates a new detached repository and prompts you to select the private key from the .ssh/authorized_keys directory of the local repository.

      By following these steps, you should be able to resolve the "Host key verification failed" error message in Git and push your changes to the repository without encountering any issues. If the error persists, you may need to check the server's configuration, authentication method, or the permissions of the repository's public key file.

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部