ssh2 icon indicating copy to clipboard operation
ssh2 copied to clipboard

Sftp server Public key auth not working through 3rd party clients

Open nowhammies opened this issue 10 years ago • 2 comments

I have created a sftp server implementation using your library which interacts with our existing webservices to provide basic sftp functionality. I have been able to implement password auth but when I went to implement publickey auth 3rd party clients would not trigger the publickey auth method. I have tried with 3 different clients (filezilla,winscp, and pcscp) to no avail.

I am posting a log from the my invocation of pscp. I am curious if I am missing something in terms of my configuration of the node sftp server. When coonnecting using a client built with the ssh2(identical to the ssh2 library example) I have no issues using the same key to authenticate.

PS C:\Program Files (x86)\PuTTY> .\pscp.exe -v -P 444 -l [email protected] -sftp -i user_private_key.ppk .\putty.chm 127.0.0.1:Putty.chm

Looking up host "127.0.0.1" Connecting to 127.0.0.1 port 444 We claim version: SSH-2.0-PuTTY_Release_0.67 Server version: SSH-2.0-ssh2js0.1.6srv Using SSH protocol version 2 Using Diffie-Hellman with standard group "group14" Doing Diffie-Hellman key exchange with hash SHA-1 Host key fingerprint is: ssh-rsa 2048 5e:72:62:fc:eb:12:46:2e:b1:77:f4:11:ae:f2:0a:6f Initialised AES-256 SDCTR client->server encryption Initialised HMAC-SHA-256 client->server MAC algorithm Initialised AES-256 SDCTR server->client encryption Initialised HMAC-SHA-256 server->client MAC algorithm Reading private key file "user_private_key.ppk" Using username "[email protected]". Disconnected: No supported authentication methods available (server sent: ) Fatal: Disconnected: No supported authentication methods available (server sent: )

Node log Listening on port 444 [20072.274783842] DEBUG: Local ident: 'SSH-2.0-ssh2js0.1.6srv' [20072.274783842] DEBUG: Parser: IN_INIT (waiting for identification begin) [20072.274783842] DEBUG: Parser: IN_INIT (waiting for rest of identification) [20072.274783842] DEBUG: Parser: IN_GREETING [20072.274783842] DEBUG: Parser: IN_HEADER Client connected! [20072.274783842] DEBUG: Remote ident: 'SSH-2.0-PuTTY_Release_0.67' [20072.274783842] DEBUG: Outgoing: Writing KEXINIT [20072.274783842] DEBUG: Parser: IN_PACKETBEFORE (expecting 8) [20072.274783842] DEBUG: Parser: IN_PACKET [20072.274783842] DEBUG: Parser: pktLen:668,padLen:10,remainLen:664 [20072.274783842] DEBUG: Parser: IN_PACKETDATA [20072.274783842] DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXINIT [20072.274783842] DEBUG: Comparing KEXINITs ... [20072.274783842] DEBUG: (local) KEX algorithms: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1 [20072.274783842] DEBUG: (remote) KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,rsa2048-sha256,rsa1024-sha1 [20072.274783842] DEBUG: KEX algorithm: diffie-hellman-group14-sha1 [20072.274783842] DEBUG: (local) Host key formats: ssh-rsa [20072.274783842] DEBUG: (remote) Host key formats: ssh-rsa,ssh-dss [20072.274783842] DEBUG: Host key format: ssh-rsa [20072.274783842] DEBUG: (local) Client->Server ciphers: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm,[email protected],aes256-gcm,[email protected] [20072.274783842] DEBUG: (remote) Client->Server ciphers: aes256-ctr,aes256-cbc,[email protected],aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc,blowfish-ctr,blowfish-cbc,3des-ctr,3des-cbc,arcfour256,arcfour128 [20072.274783842] DEBUG: Client->Server Cipher: aes256-ctr [20072.274783842] DEBUG: (local) Server->Client ciphers: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm,[email protected],aes256-gcm,[email protected] [20072.274783842] DEBUG: (remote) Server->Client ciphers: aes256-ctr,aes256-cbc,[email protected],aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc,blowfish-ctr,blowfish-cbc,3des-ctr,3des-cbc,arcfour256,arcfour128 [20072.274783842] DEBUG: Server->Client Cipher: aes256-ctr [20072.274783842] DEBUG: (local) Client->Server HMAC algorithms: hmac-sha2-256,hmac-sha2-512,hmac-sha1 [20072.274783842] DEBUG: (remote) Client->Server HMAC algorithms: hmac-sha2-256,hmac-sha1,hmac-sha1-96,hmac-md5 [20072.274783842] DEBUG: Client->Server HMAC algorithm: hmac-sha2-256 [20072.274783842] DEBUG: (local) Server->Client HMAC algorithms: hmac-sha2-256,hmac-sha2-512,hmac-sha1 [20072.274783842] DEBUG: (remote) Server->Client HMAC algorithms: hmac-sha2-256,hmac-sha1,hmac-sha1-96,hmac-md5 [20072.274783842] DEBUG: Server->Client HMAC algorithm: hmac-sha2-256 [20072.274783842] DEBUG: (local) Client->Server compression algorithms: none,[email protected],zlib [20072.274783842] DEBUG: (remote) Client->Server compression algorithms: none,zlib [20072.274783842] DEBUG: Client->Server compression algorithm: none [20072.274783842] DEBUG: (local) Server->Client compression algorithms: none,[email protected],zlib [20072.274783842] DEBUG: (remote) Server->Client compression algorithms: none,zlib [20072.274783842] DEBUG: Server->Client compression algorithm: none [20072.274783842] DEBUG: Parser: IN_PACKETBEFORE (expecting 8) [20072.274783842] DEBUG: Parser: IN_PACKET [20072.274783842] DEBUG: Parser: pktLen:268,padLen:5,remainLen:264 [20072.274783842] DEBUG: Parser: IN_PACKETDATA [20072.274783842] DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXDH_INIT [20072.274783842] DEBUG: Outgoing: Writing KEXDH_REPLY [20072.274783842] DEBUG: Outgoing: Writing NEWKEYS [20072.274783842] DEBUG: Parser: IN_PACKETBEFORE (expecting 8) [20072.274783842] DEBUG: Parser: IN_PACKET [20072.274783842] DEBUG: Parser: pktLen:12,padLen:10,remainLen:8 [20072.274783842] DEBUG: Parser: IN_PACKETDATA [20072.274783842] DEBUG: Parser: IN_PACKETDATAAFTER, packet: NEWKEYS [20072.274783842] DEBUG: Parser: IN_PACKETBEFORE (expecting 16) [20072.274783842] DEBUG: Parser: IN_PACKET [20072.274783842] DEBUG: Parser: Decrypting [20072.274783842] DEBUG: Parser: pktLen:28,padLen:10,remainLen:16 [20072.274783842] DEBUG: Parser: IN_PACKETDATA [20072.274783842] DEBUG: Parser: Decrypting [20072.274783842] DEBUG: Parser: HMAC size:32 [20072.274783842] DEBUG: Parser: IN_PACKETDATAVERIFY [20072.274783842] DEBUG: Parser: Verifying MAC [20072.274783842] DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC) [20072.274783842] DEBUG: Parser: IN_PACKETDATAAFTER, packet: SERVICE_REQUEST [20072.274783842] DEBUG: Outgoing: Writing SERVICE_ACCEPT (ssh-userauth) [20072.274783842] DEBUG: Parser: IN_PACKETBEFORE (expecting 16) [20072.274783842] DEBUG: Parser: IN_PACKET [20072.274783842] DEBUG: Parser: Decrypting [20072.274783842] DEBUG: Parser: pktLen:60,padLen:6,remainLen:48 [20072.274783842] DEBUG: Parser: IN_PACKETDATA [20072.274783842] DEBUG: Parser: Decrypting [20072.274783842] DEBUG: Parser: HMAC size:32 [20072.274783842] DEBUG: Parser: IN_PACKETDATAVERIFY [20072.274783842] DEBUG: Parser: Verifying MAC [20072.274783842] DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC) [20072.274783842] DEBUG: Parser: IN_PACKETDATAAFTER, packet: USERAUTH_REQUEST (none) [20072.274783842] DEBUG: Outgoing: Writing USERAUTH_FAILURE [20072.274783842] DEBUG: Parser: IN_PACKETBEFORE (expecting 16) [20072.274783842] DEBUG: Parser: IN_PACKET [20072.274783842] DEBUG: Parser: Decrypting [20072.274783842] DEBUG: Parser: pktLen:76,padLen:15,remainLen:64 [20072.274783842] DEBUG: Parser: IN_PACKETDATA [20072.274783842] DEBUG: Parser: Decrypting [20072.274783842] DEBUG: Parser: HMAC size:32 [20072.274783842] DEBUG: Parser: IN_PACKETDATAVERIFY [20072.274783842] DEBUG: Parser: Verifying MAC [20072.274783842] DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC) [20072.274783842] DEBUG: Parser: IN_PACKETDATAAFTER, packet: DISCONNECT (NO_MORE_AUTH_METHODS_AVAILABLE) A communications error occured in the client error was { [Error: No supported authentication methods available] code: 14 } Client disconnected

nowhammies avatar Oct 03 '16 20:10 nowhammies

Try using ctx.reject(['publickey']) instead of ctx.reject(). Some clients erroneously (strictly) rely on the auth method list returned in rejection responses.

mscdex avatar Oct 03 '16 20:10 mscdex

That was it. Thanks for the quick response!

nowhammies avatar Oct 03 '16 20:10 nowhammies