From fd22c0e3d27b22240159ca0fb6cac6c5279908c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leurent?= <131.js@cloudyks.org> Date: Sat, 20 Apr 2019 13:44:34 +0200 Subject: [PATCH 1/2] Add auth-agent@openssh.com support --- README.md | 2 ++ lib/ssh.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index 2d0d2f11..d93b50cf 100644 --- a/README.md +++ b/README.md @@ -552,6 +552,8 @@ SSH2Stream methods * **x11**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes an X11 channel open packet. `info` must contain `originAddr` and `originPort`. Returns `false` if you should wait for the `continue` event before sending any more traffic. +* **authAgent**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket) - _boolean_ - Writes an auth-agent@openssh.com channel open packet. Returns `false` if you should wait for the `continue` event before sending any more traffic. + * **openssh_forwardedStreamLocal**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes an forwarded-streamlocal@openssh.com channel open packet. `info` must contain `socketPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic. * **exitStatus**(< _integer_ >channel, < _integer_ >exitCode) - _boolean_ - Writes an exit status channel request packet. Returns `false` if you should wait for the `continue` event before sending any more traffic. diff --git a/lib/ssh.js b/lib/ssh.js index 8b4aefa9..1d76252c 100644 --- a/lib/ssh.js +++ b/lib/ssh.js @@ -1967,6 +1967,28 @@ SSH2Stream.prototype.x11 = function(chan, initWindow, maxPacket, cfg) { + ', x11)'); return send(this, buf); }; +SSH2Stream.prototype.authAgent = function(chan, initWindow, maxPacket) { + if (!this.server) + throw new Error('Server-only method called in client mode'); + + var buf = Buffer.allocUnsafe(1 + 4 + 22 + 4 + 4 + 4); + + buf[0] = MESSAGE.CHANNEL_OPEN; + + writeUInt32BE(buf, 22, 1); + buf.write('auth-agent@openssh.com', 5, 22, 'ascii'); + + writeUInt32BE(buf, chan, 27); + + writeUInt32BE(buf, initWindow, 31); + + writeUInt32BE(buf, maxPacket, 35); + + this.debug('DEBUG: Outgoing: Writing CHANNEL_OPEN (' + + chan + + ', auth-agent@openssh.com)'); + return send(this, buf); +}; SSH2Stream.prototype.openssh_forwardedStreamLocal = function(chan, initWindow, maxPacket, cfg) { if (!this.server) From b2d85e55a1c3896698283724399939987ab019f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leurent?= <131.js@cloudyks.org> Date: Sat, 20 Apr 2019 13:48:41 +0200 Subject: [PATCH 2/2] Use openssh_prefix --- README.md | 2 +- lib/ssh.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d93b50cf..32241cbc 100644 --- a/README.md +++ b/README.md @@ -552,7 +552,7 @@ SSH2Stream methods * **x11**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes an X11 channel open packet. `info` must contain `originAddr` and `originPort`. Returns `false` if you should wait for the `continue` event before sending any more traffic. -* **authAgent**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket) - _boolean_ - Writes an auth-agent@openssh.com channel open packet. Returns `false` if you should wait for the `continue` event before sending any more traffic. +* **openssh_authAgent**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket) - _boolean_ - Writes an auth-agent@openssh.com channel open packet. Returns `false` if you should wait for the `continue` event before sending any more traffic. * **openssh_forwardedStreamLocal**(< _integer_ >channel, < _integer_ >initWindow, < _integer_ >maxPacket, < _object_ >info) - _boolean_ - Writes an forwarded-streamlocal@openssh.com channel open packet. `info` must contain `socketPath`. Returns `false` if you should wait for the `continue` event before sending any more traffic. diff --git a/lib/ssh.js b/lib/ssh.js index 1d76252c..1f32bbb6 100644 --- a/lib/ssh.js +++ b/lib/ssh.js @@ -1967,7 +1967,7 @@ SSH2Stream.prototype.x11 = function(chan, initWindow, maxPacket, cfg) { + ', x11)'); return send(this, buf); }; -SSH2Stream.prototype.authAgent = function(chan, initWindow, maxPacket) { +SSH2Stream.prototype.openssh_authAgent = function(chan, initWindow, maxPacket) { if (!this.server) throw new Error('Server-only method called in client mode');