ssh2: keyboard-interactive failing for no apparent reason

I have a linux host set up that I routinely connect to through PuTTY using keyboard-interactive method, and I’ve been messing around with making my own ssh terminal client in electron.

I’m using pretty standard stuff here:

var ssh_client = require('ssh2').Client;
var conn = new ssh_client()

conn.connect({
  host: '192.168.1.103',
  port: 22,
  username: 'pi',
  tryKeyboard: true,
  readyTimeout: 99999999,
  debug: console.log
})

I didn’t include my on('keyboard-interactive', function) bause here’s the weird part: it never gets there.

As you can see, I turned on debug logging and I get this:

DEBUG: Outgoing: Writing USERAUTH_REQUEST (keyboard-interactive)
DEBUG: Parser: IN_PACKETBEFORE (expecting 16)
DEBUG: Parser: IN_PACKET
DEBUG: Parser: Decrypting
DEBUG: Parser: pktLen:44,padLen:19,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
Client: keyboard-interactive auth failed

I also turned on verbose logging on the host’s sshd service and get this:

Set /proc/self/oom_score_adj to 0
Connection from 192.168.1.100 port 1990 on 192.168.1.103 port 22
Received disconnect from 192.168.1.100: 11:  [preauth]

No other info or errors show up anywhere. It just disconnects without ever firing the keyboard-interactive event.

If you want to see any other code let me know, but like I said, none of my other code ever executes (I put in debug statements, breakpoints, you name it. Nothing.). Also, I tried simple user/pass authentication and it works flawlessly, so I know it’s just something to do with the keyboard-interactive auth method (and yes, my callback has all the correct parameters).

I hate putting these kinds of problems in “Issues” on a repo, because this is probably my fault and not your library, but I don’t know where else to ask.

Hope someone can offer some insight!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Some clients may sniff keyboard interactive prompts for ‘Password:’ or similar and use that as an alternative to the plaintext password auth method. Also, having that option enabled in PuTTY probably just means it’ll attempt that auth method as a fallback, not that it enforces its use?

Anyway, glad to hear you got it resolved now.

You’re right, that code would have failed (I had adapted some example code to try and fix the problem), but again the reason I didn’t realize that code was wrong is because that code never ever gets executed. The console.log line I have at the beginning of conn.on("keyboard-interactive" never gets called. After stepping through everything line-by-line, it seems to be failing somewhere deep within ssh.js which contains all the lower level code that ssh2 uses.

If it helps at all, I tried this and it still failed (replacing “password” with my password of course):

conn.on("keyboard-interactive", function (name, instructions, lang, prompts, finish) {
    throw new Error("WTF");
    finish(["password"]);
});

That error never gets thrown.