Ssh – Why SSH login works in shell but fails in all third parties via ssh tunnel

sshssh-tunneling

I'm using ssh to log in (prompt password first time) on a remote server.

In shell, using this command:

ssh root@myserver.com

works well! But all other db software applications that I tested (Dbeaver and Redis Desktop Manager) fail when I try to use SSH Tunnel. I selected my private key from /home/myuser/.ssh/id_dsa.

Example in Redis Desktop Manager:
rdm

Example in Dbeaver:
enter image description here

If I set the tunnel:

ssh root@myserver.com -L 6379:127.0.0.1:6379 -N

I can connect to 127.0.0.1:6379, i.e., the tunnel is working.
Why via third party is this not working?

In remote server is running CentOS 6 and in my desktop Ubuntu 14.

Best Answer

You said, in the comments,

After restarting my computer, when trying to login via ssh again, I was asked the password to unlock the id_dsa file

There's at least part of the answer. Your other tools have no ability to unlock a private key, and no ability to talk to ssh-agent to have it authenticate on their behalf. You need to remove the password from the private certificate.

The syntax is:

ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]

And as you pointed out in your comment, the practical application of this is:

ssh-keygen -p -f ~/.ssh/id_dsa

The next part of the problem is that some third-party libraries for Java and .NET will only handle RSA ssh keys - and (in my experience) only up to a certainly key length. DSA and ECDSA are not options.

If you don't have ~/.ssh/id_rsa then you are going to need to create it, and copy the public part to the remote host:

ssh-keygen -t rsa
ssh remoteuser@remotehost 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

Another part of the problem may be that the private key is in the "wrong" format and needs conversion. From a brief perusal of the documentation for Redis Desktop Manager I don't believe this is the case but it would be worth double-checking. UPDATE: It appears that JSCH - Invalid private key confirms that the key is expected to be in OpenSSH format - which is what it appears you are already using.