evsar3 / sshfs-win-manager

A GUI for SSHFS-Win (https://github.com/billziss-gh/sshfs-win)
MIT License
1.16k stars 86 forks source link

Invalid user name error when using encrypted private key #182

Open rakusan2 opened 1 year ago

rakusan2 commented 1 year ago

I have:

  1. Downloaded the latest WinFsp, SSHFS-Win, and this manager using winget
  2. Created a new config
  3. Copied the hostname and user from my .ssh/config
  4. Selected an OpenSSH ed25519 private key
  5. Tried to connect and got an invalid user name error

I have verified that the config is correct by running ssh {host}

OS: Windows 11 22H2 WinFsp: 1.12 SSHFS-Win: 3.5.20357 Manager: 1.3.1

SelcalHF commented 1 year ago

Actually, I'm having the same issue, but only when the username contains many digits.

To add more information (which may or may not match the OP issue).

Now, when I attempt to connect, the debug log shows not even the cmd run (ie. there is no reference to winning the cmd): "C:\Program Files\SSHFS-Win\bin\sshfs.exe" [ ... ]

And the GUI gives the invalid username fault. It seems there is an issue actually running the command? When I manually copy the command the manager generates with a username like "test", and modify just the username, the command runs without issue.

rakusan2 commented 1 year ago

That is interesting as neither my username nor my hostname contain any digits. My username is just tomasu

rakusan2 commented 1 year ago

Here is my debug output

Please note that I always disable password login on my ssh servers.

--------------------------------------------------------------------------------
date: 2023-02-22T18:20:49.758Z
conn: {01dd6f6f-81fa-4bf1-9352-723ad3862a57} (tomasu)
conntype: key-file
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: SSHFS version 3.5.2
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: Reading configuration data /cygdrive/c/Users/Marian/.ssh/config
debug1: /cygdrive/c/Users/Marian/.ssh/config line 1: Applying options for *
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: Connecting to tomasub.local [2604:3d09:127a:2000:bca6:b33f:4687:8ee9] port 22.
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: Connection established.
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: SSH2_MSG_KEXINIT sent
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ZsFwKrXx9Zc1BGRzbwfTJbVrcxcUqEly4boLct2/Zo8
Warning: Permanently added 'tomasub.local,2604:3d09:127a:2000:bca6:b33f:4687:8ee9' (ECDSA) to the list of known hosts.
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: SSH2_MSG_SERVICE_ACCEPT received
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: No more authentication methods to try.
tomasu@tomasub.local: Permission denied (publickey).
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} stderr: read: Connection reset by peer
{01dd6f6f-81fa-4bf1-9352-723ad3862a57} exit: 1
SelcalHF commented 1 year ago

Interesting... the result seems the same, there is no actual 'cmd' in your log, either...

rakusan2 commented 1 year ago

I have just realized that I had set a password on the private key. I have ssh-agent service running so I had forgotten about that fact.

I have created a new key without a password to test it out and it connected.

Maybe someone should look into either utilizing the ssh-agent or detecting the encrypted key and asking the user for a password.

The ssh-agent I am using is called OpenSSH Authentication Agent and is bundled with OpenSSH that is preinstalled with Windows 10 from version 1803. It has the nice feature of not asking for the password again after restarts.

Tragen commented 1 year ago

I have the same problem and found this bug. I always use encrypted keys and it would be good to ask for the password.

KrunchMuffin commented 1 year ago

So this is useless if you have keys with a passphrase?

aserrallerios commented 1 year ago

It seems to be unsupported by sshfs-win: https://github.com/winfsp/sshfs-win#unc-syntax

Not sure the UI can circumvent it.

danje57 commented 1 year ago

I've the same issue:

date: 2023-11-06T18:27:07.681Z conn: {aa4d0e80-8993-4d61-adf3-bb6d333f535d} (FL-BANK-SFTP) conntype: key-file {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: SSHFS version 3.5.2 {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: -oStrictHostKeyChecking=no> <-oUserKnownHostsFile=/dev/null> <-oPreferredAuthentications=publickey> <-oIdentityFile="C:/Users/admin/.ssh/OLD/id_rsa_empty"> <-2> <auser@XX.XX.XX.XX> <-s> <sftp> {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: Connection established. {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: identity file C:/Users/admin/.ssh/OLD/id_rsa_empty type 0 {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: identity file C:/Users/admin/.ssh/OLD/id_rsa_empty-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.4 {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: expecting SSH2_MSG_KEX_ECDH_REPLY {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: Server host key: ecdsa-sha2-nistp256 SHA256:eJYm5c3SenRqA2slQXQKEbG1zvbOai/YitasPUvCU90 {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: SSH2_MSG_SERVICE_ACCEPT received {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: Authentications that can continue: password,publickey,keyboard-interactive debug1: Next authentication method: publickey {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: Offering public key: C:/Users/admin/.ssh/OLD/id_rsa_empty RSA SHA256:ICQ4zrkZC019t1HB5Bl5mn1vw4VqmWPrzno0Py85g4s explicit {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: debug1: Server accepts key: C:/Users/admin/.ssh/OLD/id_rsa_empty RSA SHA256:ICQ4zrkZC019t1HB5Bl5mn1vw4VqmWPrzno0Py85g4s explicit Load key "C:/Users/admin/.ssh/OLD/id_rsa_empty": invalid format debug1: No more authentication methods to try. auser@XX.XX.XX.XX: Permission denied (password,publickey,keyboard-interactive). {aa4d0e80-8993-4d61-adf3-bb6d333f535d} stderr: read: Connection reset by peer {aa4d0e80-8993-4d61-adf3-bb6d333f535d} exit: 1

I tried with no passphrase, with passphrase it is the same

I tried with key generated byopenssh and putty, it is the same...

However whith SFTP Drive it works.... so key and configuration are goods.

LeoShivas commented 2 months ago

With Notepad++, please :

That has solved my problem.

KrunchMuffin commented 2 months ago

mine is already set like that