Fix - DBeaver SSH tunnel connections fail with invalid privatekey error

Invalid privatekey error in DBeaver

I tried to connect to a remote Postgresql server with DBeaver and got this error today. The error message said my private key was invalid. To check this further, I tried to login to the server using the terminal as usual and it worked. So I realized the issue must be in DBeaver, and not in my private key.
After a few google searches, I learned that DBeaver does not support new OpenSSH private keys format by default. So as a workaround, I had to convert my key file to old PEM format using the following command and use it with DBeaver.

This will work if you already generated the keys with new format and want to use them with DBeaver.

ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
If you want to generate new keys, use the following.

ssh-keygen -t rsa -b 4096 -m PEM

That’s it. I hope this will help someone.

2 comments :

  1. after covert, the following error was showed, SSH_MSG_DISCONNECT: 2 Too many authentication failures

    ReplyDelete
  2. Thank you so much!
    Your solution worked for my case!

    My scenario:
    MacOS 10.13.6
    DBeaver 7.2.3
    SSH private key == ECDSA 521 SHA256
    SSH client (ssh -V) == "OpenSSH_7.8p1, LibreSSL 2.6.2"
    SSH server (sshd -V) == "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017"

    ReplyDelete