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

dbeaverpostgresqlssh

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

enter image description here

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:

enter image description here

enter image description here

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.

Best Answer

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:

  1. Disable the SSH Tunnel:

enter image description here

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

  2. Add the shell command in your connection in DBeaver:

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

enter image description here

  1. 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.