Skip to content

Instantly share code, notes, and snippets.

@ahultgren
Created May 26, 2014 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahultgren/63bbec3f5b94ca573489 to your computer and use it in GitHub Desktop.
Save ahultgren/63bbec3f5b94ca573489 to your computer and use it in GitHub Desktop.
Reproduction of a bug in ssh2 when using agent forwarding
var Connection = require('ssh2');
var conn = new Connection();
conn.on('ready', function() {
exec(conn, 'pwd', function () {
exec(conn, 'pwd', function () {
conn.end();
});
});
});
conn.on('keyboard-interactive', function (_0, _1, _2, prompt, callback) {
callback(['***']);
});
conn.connect({
host: '1.2.3.4',
username: 'me',
agent: process.env.SSH_AUTH_SOCK,
agentForward: true,
tryKeyboard: true
});
function exec (conn, command, callback) {
conn.exec(command, function(err, stream) {
if (err) throw err;
stream.on('data', function(data, stderr) {
if (stderr)
console.log('STDERR: ' + data);
else
console.log('STDOUT: ' + data);
}).on('exit', function(exitcode) {
callback();
});
});
}
{ '0': '',
'1': '',
'2': '',
'3': [ { prompt: 'Password:', echo: false } ],
'4': [Function] }
STDOUT: /a/path
/Users/andreashultgren/Documents/Projects/Temp/sshtest.js:31
if (err) throw err;
^
Error: Unable to request agent forwarding
at /Users/andreashultgren/Documents/Projects/Temp/node_modules/ssh2/lib/Channel.js:198:17
at Parser.<anonymous> (/Users/andreashultgren/Documents/Projects/Temp/node_modules/ssh2/lib/Channel.js:128:30)
at Parser.EventEmitter.emit (events.js:92:17)
at Parser.parsePacket (/Users/andreashultgren/Documents/Projects/Temp/node_modules/ssh2/lib/Parser.js:637:12)
at Parser.execute (/Users/andreashultgren/Documents/Projects/Temp/node_modules/ssh2/lib/Parser.js:249:14)
at Socket.<anonymous> (/Users/andreashultgren/Documents/Projects/Temp/node_modules/ssh2/lib/Connection.js:521:18)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:745:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:407:10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment