mscdex / ssh2

SSH2 client and server modules written in pure JavaScript for node.js
MIT License
5.52k stars 664 forks source link

SSH connection fails for password auth #533

Closed steverob closed 5 years ago

steverob commented 7 years ago

I'm trying to connect to my server using password auth but I keep getting the error - All configured authentication methods failed.

Debug output - https://gist.github.com/steverob/c0731e561d8c7ee479d567156851b11b

Connecting using public key to the same server works successfully. And when I try to use Ruby's net/sftp with password auth, it works well too.

Could you help me out here? Thanks!

Version: "ssh2": "^0.5.4" | Node - 6.4.0

mscdex commented 7 years ago

My guess is that you actually want the 'keyboard-interactive' auth mechanism (which is often used for interactive password prompts). For that, you will need to add a 'keyboard-interactive' event handler. See the documentation for more information.

steverob commented 7 years ago

Thanks for the reply. Actually I have specified the password with the 'password' attribute in the Configg object. Should i still have to enter password interactively?

-- Regards Steve Robinson

On 02-Mar-2017, at 4:22 PM, Brian White notifications@github.com wrote:

My guess is that you actually want the 'keyboard-interactive' auth mechanism (which is often used for interactive password prompts). For that, you will need to add a 'keyboard-interactive' event handler. See the documentation for more information.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

mscdex commented 7 years ago

If using password: '...' does not work, then it must be using keyboard-interactive, so you will need to handle that event and add tryKeyboard: true to your config object.

codekraft-studio commented 7 years ago

I got the same problem with both password and key, but I know they works because i'm using them with another ssh client. here a snippet of the debug log:

DEBUG: Outgoing: Writing SERVICE_REQUEST (ssh-userauth)
DEBUG: Parser: IN_PACKETBEFORE (expecting 16)
DEBUG: Parser: IN_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:28,padLen:10,remainLen:16
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: HMAC size:32
DEBUG: Parser: IN_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC)
DEBUG: Parser: IN_PACKETDATAAFTER, packet: SERVICE_ACCEPT
DEBUG: Outgoing: Writing USERAUTH_REQUEST (password)
DEBUG: Parser: IN_PACKETBEFORE (expecting 16)

DEBUG: Parser: IN_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:44,padLen:7,remainLen:32
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: HMAC size:32
DEBUG: Parser: IN_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC)
DEBUG: Parser: IN_PACKETDATAAFTER, packet: USERAUTH_FAILURE
DEBUG: Client: password auth failed
DEBUG: Outgoing: Writing USERAUTH_REQUEST (publickey -- check)
DEBUG: Parser: IN_PACKETBEFORE (expecting 16)
DEBUG: Parser: IN_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:44,padLen:7,remainLen:32
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: HMAC size:32
DEBUG: Parser: IN_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC)
DEBUG: Parser: IN_PACKETDATAAFTER, packet: USERAUTH_FAILURE
DEBUG: Client: publickey auth failed
DEBUG: Outgoing: Writing USERAUTH_REQUEST (none)
DEBUG: Parser: IN_PACKETBEFORE (expecting 16)
DEBUG: Parser: IN_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:44,padLen:7,remainLen:32
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: Decrypting
DEBUG: Parser: HMAC size:32
DEBUG: Parser: IN_PACKETDATAVERIFY
DEBUG: Parser: Verifying MAC
DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC)
DEBUG: Parser: IN_PACKETDATAAFTER, packet: USERAUTH_FAILURE
DEBUG: Client: none auth failed

why is failing? i'm sure 100% the password and/or the key file works

gdemarcos commented 7 years ago

I am facing this same error with my ssh client. We are using public/private key auth with passphrase - no password. I know the key configuration is correct because I tested it (before including socksv5 to connect through a proxy). The proxy is working as expected and the logs for the incoming connection on the server reflect the proxy IP address. Here is the debug on the client:

DEBUG: Local ident: 'SSH-2.0-ssh2js0.0.23' DEBUG: Outgoing: Writing KEXDH_GEX_INIT DEBUG: Parser: IN_PACKETBEFORE (expecting 8) DEBUG: Parser: IN_PACKET DEBUG: Parser: pktLen:956,padLen:7,remainLen:952 DEBUG: Parser: IN_PACKETDATA DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXDH_GEX_REPLY DEBUG: Checking host key format DEBUG: Checking signature format DEBUG: Verifying host fingerprint DEBUG: Host accepted by default (no verification) DEBUG: Verifying signature DEBUG: Outgoing: Writing NEWKEYS DEBUG: Parser: IN_PACKETBEFORE (expecting 8) DEBUG: Parser: IN_PACKET DEBUG: Parser: pktLen:12,padLen:10,remainLen:8 DEBUG: Parser: IN_PACKETDATA DEBUG: Parser: IN_PACKETDATAAFTER, packet: NEWKEYS DEBUG: Outgoing: Writing SERVICE_REQUEST (ssh-userauth) DEBUG: Parser: IN_PACKETBEFORE (expecting 16) DEBUG: Parser: IN_PACKET DEBUG: Parser: Decrypting DEBUG: Parser: pktLen:28,padLen:10,remainLen:16 DEBUG: Parser: IN_PACKETDATA DEBUG: Parser: Decrypting DEBUG: Parser: HMAC size:16 DEBUG: Parser: IN_PACKETDATAVERIFY DEBUG: Parser: Verifying MAC DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC) DEBUG: Parser: IN_PACKETDATAAFTER, packet: SERVICE_ACCEPT DEBUG: Outgoing: Writing USERAUTH_REQUEST (publickey -- check) DEBUG: Parser: IN_PACKETBEFORE (expecting 16) DEBUG: Parser: IN_PACKET DEBUG: Parser: Decrypting DEBUG: Parser: pktLen:60,padLen:14,remainLen:48 DEBUG: Parser: IN_PACKETDATA DEBUG: Parser: Decrypting DEBUG: Parser: HMAC size:16 DEBUG: Parser: IN_PACKETDATAVERIFY DEBUG: Parser: Verifying MAC DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC) DEBUG: Parser: IN_PACKETDATAAFTER, packet: USERAUTH_FAILURE DEBUG: Client: publickey auth failed DEBUG: Outgoing: Writing USERAUTH_REQUEST (none) DEBUG: Parser: IN_PACKETBEFORE (expecting 16) DEBUG: Parser: IN_PACKET DEBUG: Parser: Decrypting DEBUG: Parser: pktLen:60,padLen:14,remainLen:48 DEBUG: Parser: IN_PACKETDATA DEBUG: Parser: Decrypting DEBUG: Parser: HMAC size:16 DEBUG: Parser: IN_PACKETDATAVERIFY DEBUG: Parser: Verifying MAC DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC) DEBUG: Parser: IN_PACKETDATAAFTER, packet: USERAUTH_FAILURE DEBUG: Client: none auth failed { [Error: All configured authentication methods failed] level: 'client-authentication' } DEBUG: Outgoing: Writing DISCONNECT (BY_APPLICATION)

Any guidance on this is greatly appreciated.

"node": "0.12.7", "socksv5": "0.0.6", "ssh2": "0.4.12"

mscdex commented 7 years ago

@gdemarcos I don't know what to suggest for your situation. The server is saying it doesn't know about the one key you're sending.

gdemarcos commented 7 years ago

@mscdex Thanks for the clarification on my issue. :+1:

mscdex commented 7 years ago

@codekraft-studio Did you try using keyboard-interactive for password input ?