Getting 'Packet corrupt' messages for any attempted connection.
Trying out the sample code from the readme, but only getting 'Packet corrupt' messages from any host I try. Running on OSX with node 0.10.2 and ssh2 0.4.6. I am using password rather than an auth key, but the rest of the code is identical to the sample:
var Client = require('ssh2').Client;
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');
conn.exec('uptime', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
conn.end();
}).on('data', function(data) {
console.log('STDOUT: ' + data);
}).stderr.on('data', function(data) {
console.log('STDERR: ' + data);
});
});
}).connect({
host: '10.10.100.1',
port: 22,
username: 'root',
password: 'root'
});
I've tried this towards RHEL 7.0, Ubuntu 14.x, Windows 7, OSX 10.10, and F5 BIGIP 11.6....all get the same results. Here's the error output:
$ node test2.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: Packet corrupt
at onDISCONNECT (/Users/joallen/_Dev/Node.js/assessNode/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:2033:15)
at SSH2Stream.<anonymous> (/Users/joallen/_Dev/Node.js/assessNode/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:179:5)
at SSH2Stream.EventEmitter.emit (events.js:106:17)
at parsePacket (/Users/joallen/_Dev/Node.js/assessNode/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:3403:10)
at SSH2Stream._transform (/Users/joallen/_Dev/Node.js/assessNode/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:555:13)
at SSH2Stream.Transform._read [as __read] (_stream_transform.js:181:10)
at SSH2Stream._read (/Users/joallen/_Dev/Node.js/assessNode/node_modules/ssh2/node_modules/ssh2-streams/lib/ssh.js:213:15)
at SSH2Stream.Transform._write (_stream_transform.js:169:12)
at doWrite (_stream_writable.js:211:10)
at writeOrBuffer (_stream_writable.js:201:5)
I can connect to all the test nodes from my command line using ssh just fine. Thanks!
Can you try upgrading to a newer version of node and try again? At least node v0.10.38?
When you say "tried this towards" do you mean you were connecting from those platforms or to them?
Can you set debug: console.log in the connection config options and post the output somewhere?
Debug Output:
$ node ./lib/test2.js
DEBUG: Local ident: 'SSH-2.0-ssh2js0.0.9'
DEBUG: Client: Trying 10.147.29.25 on port 22 ...
DEBUG: Client: Connected
DEBUG: Parser: IN_INIT
DEBUG: Parser: IN_GREETING
DEBUG: Parser: IN_HEADER
DEBUG: Remote ident: 'SSH-2.0-OpenSSH_6.4'
DEBUG: Outgoing: Writing KEXINIT
DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
DEBUG: Parser: IN_PACKET
DEBUG: Parser: pktLen:1532,padLen:7,remainLen:1528
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXINIT
DEBUG: Comparing KEXINITs ...
DEBUG: (local) KEX algorithms: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
DEBUG: (remote) KEX algorithms: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
DEBUG: KEX algorithm: diffie-hellman-group14-sha1
DEBUG: (local) Host key formats: ssh-rsa,ssh-dss
DEBUG: (remote) Host key formats: ssh-rsa,ecdsa-sha2-nistp256
DEBUG: Host key format: ssh-rsa
DEBUG: (local) Client->Server ciphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,arcfour256,arcfour128,cast128-cbc,arcfour
DEBUG: (remote) Client->Server ciphers: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
DEBUG: Client->Server Cipher: aes256-ctr
DEBUG: (local) Server->Client ciphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,arcfour256,arcfour128,cast128-cbc,arcfour
DEBUG: (remote) Server->Client ciphers: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
DEBUG: Server->Client Cipher: aes256-ctr
DEBUG: (local) Client->Server HMAC algorithms: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
DEBUG: (remote) Client->Server HMAC algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
DEBUG: Client->Server HMAC algorithm: hmac-md5
DEBUG: (local) Server->Client HMAC algorithms: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
DEBUG: (remote) Server->Client HMAC algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
DEBUG: Server->Client HMAC algorithm: hmac-md5
DEBUG: (local) Client->Server compression algorithms: none
DEBUG: (remote) Client->Server compression algorithms: none,[email protected]
DEBUG: Client->Server compression algorithm: none
DEBUG: (local) Server->Client compression algorithms: none
DEBUG: (remote) Server->Client compression algorithms: none,[email protected]
DEBUG: Server->Client compression algorithm: none
DEBUG: Outgoing: Writing KEXDH_INIT
DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
DEBUG: Parser: IN_PACKET
DEBUG: Parser: pktLen:828,padLen:8,remainLen:824
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXDH_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:44,padLen:16,remainLen:32
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: DISCONNECT (PROTOCOL_ERROR)
events.js:72
throw er; // Unhandled 'error' event
ssh command line to same host:
$ ssh [email protected] uptime
[email protected]'s password:
09:02:44 up 41 days, 23:35, 0 users, load average: 0.08, 0.10, 0.13
These are connections from my OSX node TO my test nodes (IE> "towards") :)
I should have a chance to try a newer node version later today...will try my test program again after that.
Thanks :)
I was able to duplicate the problem and it does appear to be specific to that node version. Upgrading node should work.
Confirmed: Upgraded to Node 0.12.2 and no issues when running the sample code. Thanks for your help! :)