HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

DBeaver: connecting to a PostgreSQL database server through SSH: can't initialize tunnel, auth fail

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlcanauthconnectingdbeaverfaildatabasetunnelthroughserver

Problem

I am trying to use DBeaver to connect to a PostgreSQL database server through SSH:

can't initialize tunnel
cannot establish tunnel
com.jcraft.jsch.JSchException: auth fail


I am sure the SSH server is working fine. I manage to connect to the same PostgreSQL database server through the same SSH server with pgAdmin 3 and RazorSQL. I have checked the IP, username and password, they are correct. I disabled all firewalls. What could be the issue?

My settings:

I use DBeaver 3.7.3 x64 portable version with Windows 7 SP1 x64 Ultimate.

The error log window does not log the error, so I don't have any more information there.

Solution

I tried DBweaver on Kubuntu and had the same issue. It looks like the issue is around the fact that the authenticity of the SSH server hadn't been verified beforehand, and DBweaver and unable to cascade the correct error message (e.g., Host key verification failed.) and instead misleadingly blames some authentication error.

I fixed the issue on Kubuntu as follows:

  • Disable the SSH Tunnel:



-
Run in the shell sudo apt-get install -y autossh

-
Add the shell command in your connection in DBeaver:

autossh -f -N -L 5432:localhost:5432 ssh_server_username@ssh_server_ip


-
At that point if you try to connect you'll have the same com.jcraft.jsch.JSchException: auth fail error message. Go to the shell and run the command:

ssh -f -N -L 5432:localhost:5432 ssh_server_username@ssh_server_ip


it will output:

The authenticity of host 'ssh_server_hostname (ssh_server_ip)' can't be established.
ECDSA key fingerprint is 29:13:b5:cb:99:21:b2:18:f1:11:aa:12:54:c2:88:9a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ssh_server_hostname,ssh_server_ip' (ECDSA) to the list of known hosts.
Password:


Go back to DBeaver, try to connect, that should work. I still don't know why I should use autossh instead of the SSH tunnel tab in DBeaver though.

Code Snippets

autossh -f -N -L 5432:localhost:5432 ssh_server_username@ssh_server_ip
ssh -f -N -L 5432:localhost:5432 ssh_server_username@ssh_server_ip
The authenticity of host 'ssh_server_hostname (ssh_server_ip)' can't be established.
ECDSA key fingerprint is 29:13:b5:cb:99:21:b2:18:f1:11:aa:12:54:c2:88:9a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ssh_server_hostname,ssh_server_ip' (ECDSA) to the list of known hosts.
Password:

Context

StackExchange Database Administrators Q#148712, answer score: 5

Revisions (0)

No revisions yet.