Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DBeaver ssh tunnel invalid private key

Just want to leave it here, so the link to the solution won't be lost.

I have a private 4096-byte RSA key (probably it was generated using this guide https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

I've got an error while trying to establish a new connection through an ssh tunnel using DBeaver (6.1.2).


invalid privatekey: [B@540.....

like image 327
zinovyev Avatar asked Jul 10 '19 23:07

zinovyev


4 Answers

  1. So at first I've found this solution: https://github.com/rundeck/rundeck/issues/4813#issuecomment-492358649 But I didn't really want to recreate my key, cause it was already in use on several servers.

  2. After an hour of googling I've found another suggestion: to use another SSH implementation via the sshj extension: https://github.com/dbeaver/dbeaver/issues/3917#issuecomment-410616717 It can be installed via the built-in package manager: Help -> Install New Software -> https://dbeaver.io/update/sshj/latest/ And it works great!

like image 158
zinovyev Avatar answered Oct 17 '22 04:10

zinovyev


This error is due to the format of the SSH private key. By default, ssh-keygen is creating a private key using the OpenSSH format—with this header:

-----BEGIN OPENSSH PRIVATE KEY-----

But DBeaver only accept keys using the older PEM format—with this header:

-----BEGIN RSA PRIVATE KEY-----

You can either generate a key directly with the correct header using:

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

Or you can convert an existing key (careful! this overwrite the existing key, you can just copy the private key and apply the command on the copy):

ssh-keygen -p -m PEM -f id_rsa

There is an open issue on DBeaver's GitHub.

like image 36
tupui Avatar answered Oct 17 '22 02:10

tupui


I got the SSH Tunnel to work on DBeaver Community Edition Version 7.3.4.202101310933 macOS Catalina version 10.15.7 by doing the following:

in shell: create private 4096-byte RSA key at default location ~/.ssh/id_rsa using ssh-keygen -t rsa -b 4096

in DBeaver:

  • click Help > Install New Software
  • click Add ...
  • enter Name: SSHJ
  • enter Location: https://dbeaver.io/update/sshj/latest/
  • click Next and go thru the entire SSHJ installation process (I failed to do this on my first attempt)
  • click Save
  • click Restart DBeaver

on SSH Tunnel tab of Connection Settings

  • use Authentication Method: Public Key
  • use Private Key: ~/.ssh/id_rsa (OpenSSH NOT PEM, as others have advised)
  • enter Passphrase
  • select Save Password
  • select Implentation: SSHJ
  • click Test tunnel configuration

modal dialog is displayed that says

Connected!
Client version: SSHJ_0.27.0
Server version: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
  • click OK
like image 44
Shawn Becker Avatar answered Oct 17 '22 02:10

Shawn Becker


The above suggestions didn't help for me. But in the latest versions of DBeaver, you just have to update implementation to SSHJ, under Advanced settings:

enter image description here

That worked for me!

like image 7
Fernando Wittmann Avatar answered Oct 17 '22 04:10

Fernando Wittmann