ellie-commons / sequeler

SQL Client built in Vala
GNU General Public License v3.0
805 stars 66 forks source link

Unable to connect via SSH #345

Open mayaagency opened 4 years ago

mayaagency commented 4 years ago

When I select a key I get a yellow box appear saying "Missing SSH public key!" with a button labelled "Generate SSH Key".

Maybe I'm missing something, but I don't understand what I'm supposed to do here. Both a public and private key exist, named id_rsa and id_rsa.pub respectively and I can use them to connect to the server via ssh on the command line. The keys don't have a passphrase. I've tried selecting both of these files but get the same error either way.

If I ignore this warning and test the connection I get "Failed to connect!"

rizjoj commented 4 years ago

I'm getting this too, except I know my id_rsa and ssh host, etc. are correct as this works (and has been for years) on my mac client (querious) using the same info. I can connect fine without tunneling but my use case is to connect over the tunnel as a super user.

mipmip commented 4 years ago

I had the same problem. Tried debugging with: G_MESSAGES_DEBUG=all com.github.alecaddd.sequeler, with connectionManager.vala open for reference. Once I changed localhost to 127.0.0.1 and replaced my key for a password, I could connect.

mipmip commented 4 years ago

I can confirm DNS hostnames do not work. And private keys do not work. When using ip addresses and passwords connections can be made.

janiluuk commented 4 years ago

i can confirm also, private keys are useless with this.

adhisimon commented 4 years ago

I can confirm this also on Fedora 33. I'm sure my key is valid. I can use this key using other ssh client. Sequeler can access ssh tunnel only using ssh password.

albertcat commented 3 years ago

Same problem here (Pop OS). It seems it ignores the "SSH Identity" field. It keeps displaying "Missing SSH Key File!"

Alecaddd commented 3 years ago

I think this is an issue of the Flatpak file. @bilelmoussaoui, would you know how to give the flatpak access to the user's ~/.ssh directory?

lil5 commented 3 years ago

This helped me fix file permissions:

https://askubuntu.com/a/1094903

sudo flatpak override com.github.alecadddd.sequeler --filesystem=home

You can also use Flatseal and edit the permissions graphically https://flathub.org/apps/details/com.github.tchx84.Flatseal

@Alecaddd I'm afraid that this still shows the errors explained above

lil5 commented 3 years ago

@Alecaddd I have found this in the logs

** (Sequeler:2): DEBUG: 14:58:52.509: PasswordManager.vala:50: Unable to fetch password in libsecret keyring for com.github.alecaddd.sequeler.29999
** (Sequeler:2): DEBUG: 14:58:52.510: ConnectionManager.vala:156: Opening tunnel 0x559e593652a0
** (Sequeler:2): DEBUG: 14:58:52.510: ConnectionManager.vala:196: Socket params: my.host.eu 1234
** (Sequeler:2): DEBUG: 14:58:52.510: ConnectionManager.vala:210: Failed to connect!
** (Sequeler:2): DEBUG: 14:58:52.510: ConnectionManager.vala:150: Failed to connect!
** (Sequeler:2): DEBUG: 14:59:12.006: ConnectionManager.vala:408: closing ssh tunnel from: ConnectionDialog.vala:617 0x559e589e4790
henkedk commented 3 years ago

(Sequeler:2): DEBUG: 22:03:20.450: ConnectionManager.vala:196: Socket params: ip port (Sequeler:2): DEBUG: 22:03:20.606: ConnectionManager.vala:229: Authentication methods: publickey,password (Sequeler:2): DEBUG: 22:03:20.632: ConnectionManager.vala:240: Authentication by password failed. (Sequeler:2): DEBUG: 22:03:20.632: ConnectionManager.vala:408: closing ssh tunnel from: ConnectionManager.vala:241 0x55d965ba95e0 ** (Sequeler:2): DEBUG: 22:03:20.632: ConnectionManager.vala:150: Authentication by password failed!

Used flatseal to give acces to ~/.ssh (which made the "Missing public key" message go away.

Still cannot connect (and I can connect to the remote box with a normal terminal just fine using that exact key.

It seems as if the connection manager tries to use the password auth first (my password field is empty and pw login on the remote box is disabled) and it never gets to the part of using the actual keyfile.

I also tried moving a copy of the keyfile directly to my /home without .ssh - same result.

@Alecaddd seems you have a bug here, even if a keyfile is used, password auth is tried first, if it fails, mission is aborted.

henkedk commented 3 years ago

@Alecaddd FYI I compiled from scratch, taking out the following from ConnectionManager.vala - now I can log in with ssh key just fine, so my suggestion about the auth manager trying to use a PW first even if the user entered none is true

    if ((auth_pw & Auth.PASSWORD) != 0) {
        if (session.auth_password (username, password) != SSH2.Error.NONE) {
            debug ("Authentication by password failed.");
            ssh_tunnel_close (Log.FILE + ":" + Log.LINE.to_string ());
            throw new Error.literal (q, 1, _("Authentication by password failed!"));
        }
    } else
Alecaddd commented 3 years ago

@henkedk sweet, thanks for checking this. Feel free to open a PR if you want, otherwise I will take care of this later next week.

bilelmoussaoui commented 3 years ago

I think this is an issue of the Flatpak file. @bilelmoussaoui, would you know how to give the flatpak access to the user's ~/.ssh directory?

with passing --filesystem=~/.ssh to the flatpak manifest's finish-args which already has iirc. Maybe worth trying with a wider permission like home or host?

towo commented 2 years ago

Keys work, hostname is still bogus, fwiw (0.8.0)