11

While using git clone in PhpStorm, I got an error message:

Clone failed
Unable to negotiate with IP ADDRESS port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

I then made my own RSA key in and saved it on my computer; also registered it on the server (by server host) where I wanted to get git clone. I've also downgraded my latest PhpStorm version. As a last resort I have also reset my computer and reinstalled PhpStorm.

But I still have that error message in my PhpStorm event log.

Plus, when I first got PhpStorm, I could easily get clone successfully, but suddenly after days, I've got event log entries like that.

Can I get a solution about this, OTL

Still here
  • 111
  • 1
  • 1
  • 5
  • We need to check IDE debug logs to advise. Please contact the support team via Help | Contact Support to investigate this further. – Dmitrii Apr 05 '22 at 09:20
  • What is your git version? Since Git 2.33 the openssh that comes with Git deprecated DSA keys by default. Quick solution => downgrade to Git 2.32. – danieltc07 Apr 29 '22 at 13:43

7 Answers7

38

On Linux/Ubuntu I added the following lines to /etc/ssh/ssh_config:

    PubkeyAcceptedAlgorithms +ssh-rsa
    HostkeyAlgorithms +ssh-rsa

I guess it is equivalent (and better) to put the same lines in a separate file in /etc/ssh/ssh_config.d.

  • 1
    If you can't edit the system /etc/ssh version, copy it to ~/.ssh/config to have your personal copy that you can manage yourself. (Also works with Git Bash on WIndows) – Ben Ketteridge Jun 27 '22 at 14:48
  • Thanks. That solved my problem of not being able to ssh into my shared hosting account at HostGator that started happening after upgrading from Ubuntu 20.04 to Ubuntu 22.04 – 1GLENCo Aug 28 '22 at 13:44
  • 1
    This begs the question, why isn't it enabled by default? Is it insecure? – Brōtsyorfuzthrāx Sep 30 '22 at 03:17
  • 1
    Please do not enable the weaker cryptographic algorithms for all hosts. Put the options for example under `Host` like in the other answers here. – pabouk - Ukraine stay strong Oct 14 '22 at 17:31
18

Add PubkeyAcceptedAlgorithms +ssh-rsa and HostkeyAlgorithms +ssh-rsa attributes.

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
Antonio Moreno
  • 881
  • 8
  • 9
3

This is because OpenSSH have deprecated ssh-rsa.
To enable it, add -oHostKeyAlgorithms=+ssh-rsa to your command.

Orace
  • 7,822
  • 30
  • 45
Hoxfor
  • 31
  • 2
0

Check, as in here, if using a private key without passphrase improves the situation.

Check also settings>Version Control>git >SSH Executable: try system instead of "native", and double-check your %PATH% (Windows) or $PATH (Linux/Mac).

On Windows, I would make sure C:\Program files\Git\usr\bin\ssh.exe comes first.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

If you are on Windows, try this.

  1. Follow these commands. You can generate id_rsa file and id_rsa.pub. Basically, These files can be found on ~/.ssh directory.
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. Create a config on ~/.ssh directory and paste these attributes.
# 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
  • You should change the Host and IdentityFile accordingly. For example: IdentityFile ~/.ssh/id_rsa.
  • Please note these attributes. PubkeyAcceptedAlgorithms +ssh-rsa and HostkeyAlgorithms +ssh-rsa
  1. Try this command and verify that your SSH key was added correctly.
ssh -T git@gitlab.example.com

References: https://docs.gitlab.com/ee/user/ssh.html#rsa-ssh-keys

Dhanusha_Perera07
  • 3,347
  • 5
  • 14
  • 22
0

It's work for me , enter ssh config with this command , sudo nano /etc/ssh/ssh_config and then add follow new two line into your ssh config ,

PubkeyAcceptedAlgorithms +ssh-rsa

HostkeyAlgorithms +ssh-rsa

save and exit login again ssh if you got this message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" type this command and hit enter , rm .ssh/known_hosts try login again ssh. my English is bad sorry for inconvinience

PZee
  • 1
  • 1
0

Try these commands:

apt update
apt install rsh-client

Then try this again.

rslogin -l user hostIP
Saving Red
  • 21
  • 5