【问题标题】:Unable to negotiate with __IP_ADDRESS_ port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss无法与 __IP_ADDRESS_ 端口 22 协商:找不到匹配的主机密钥类型。他们的提议:ssh-rsa,ssh-dss
【发布时间】:2022-08-03 21:06:53
【问题描述】:

在 PhpStorm 中使用 git clone 时,我收到一条错误消息:

克隆失败
无法与 IP ADDRESS 端口 22 协商:找不到匹配的主机密钥类型。他们的提议:ssh-rsa,ssh-dss
无法从远程存储库中读取。
请确保您具有正确的访问权限并且存储库存在。

然后我制作了自己的 RSA 密钥并将其保存在我的计算机上; 还在我想要获取 git clone 的服务器(通过服务器主机)上注册它。我还降级了我最新的 PhpStorm 版本。作为最后的手段,我还重置了我的计算机并重新安装了 PhpStorm。

但是我的 PhpStorm 事件日志中仍然有该错误消息。

另外,当我第一次获得 PhpStorm 时,我可以轻松地成功克隆,但几天后突然,我得到了这样的事件日志条目。

我能得到一个解决方案吗,OTL

  • 我们需要检查 IDE 调试日志以提供建议。请通过帮助联系支持团队 |联系支持人员以进一步调查此问题。
  • 你的 git 版本是多少?从 Git 2.33 开始,Git 附带的 openssh 默认不推荐使用 DSA 密钥。快速解决方案 => 降级到 Git 2.32。

标签: git intellij-idea phpstorm rsa git-clone


【解决方案1】:

在 Linux/Ubuntu 上,我在/etc/ssh/ssh_config 中添加了以下几行:

    PubkeyAcceptedAlgorithms +ssh-rsa
    HostkeyAlgorithms +ssh-rsa

我想将相同的行放在/etc/ssh/ssh_config.d 的单独文件中是等效的(并且更好)。

【讨论】:

  • 如果您无法编辑系统 /etc/ssh 版本,请将其复制到 ~/.ssh/config 以获得您可以自己管理的个人副本。 (也适用于 Windows 上的 Git Bash)
【解决方案2】:

添加PubkeyAcceptedAlgorithms +ssh-rsaHostkeyAlgorithms +ssh-rsa 属性。

nano ~/.ssh/config
Host hostname_of_machine
    HostName hostname_or_ip_address
    User root
    IdentityFile ~/.ssh/file.pem
    IdentitiesOnly yes
    PubkeyAcceptedAlgorithms +ssh-rsa
    HostkeyAlgorithms +ssh-rsa

【讨论】:

    【解决方案3】:

    检查,如in here,如果使用私钥没有密码可以改善这种情况。

    还要检查settings>Version Control>git >SSH Executable:尝试使用系统而不是“本机”,并仔细检查您的%PATH% (Windows) 或$PATH (Linux/Mac)。

    在 Windows 上,我会确保 C:\Program files\Git\usr\bin\ssh.exe 排在第一位。

    【讨论】:

      【解决方案4】:

      如果你在 Windows 上,试试这个。

      1. 遵循这些命令。您可以生成id_rsa 文件和id_rsa.pub。基本上,这些文件可以在~/.ssh 目录中找到。
        cat ~/.ssh/id_rsa.pub
        
        ssh-keygen -o -t rsa -b 4096 -C "email@example.com"
        
        cat ~/.ssh/id_rsa.pub | clip
        
        ssh -T git@gitlab.example.com
        
        1. ~/.ssh 目录上创建config 并粘贴这些属性。
        # GitLab.com
        Host gitlab.com
          PreferredAuthentications publickey
          IdentityFile ~/.ssh/gitlab_com_rsa
        
        # Private GitLab instance
        Host gitlab.company.com
          PreferredAuthentications publickey
          IdentityFile ~/.ssh/example_com_rsa
          PubkeyAcceptedAlgorithms +ssh-rsa
          HostkeyAlgorithms +ssh-rsa
        
        • 您应该相应地更改HostIdentityFile。例如:IdentityFile ~/.ssh/id_rsa
        • 请注意这些属性。 PubkeyAcceptedAlgorithms +ssh-rsaHostkeyAlgorithms +ssh-rsa
        1. 尝试此命令并验证您的 SSH 密钥是否已正确添加。
        ssh -T git@gitlab.example.com
        

        参考文献:https://docs.gitlab.com/ee/user/ssh.html#rsa-ssh-keys

      【讨论】:

        猜你喜欢
        • 2021-12-20
        • 2021-04-14
        • 2016-05-15
        • 2017-10-14
        • 1970-01-01
        • 1970-01-01
        • 2013-09-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多