From 05f4319aa070c74b967b3ad2342e4d2243980cbf Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 17 Oct 2019 12:22:15 -0400 Subject: [PATCH] Support user from ssh://user@host, and agent from env --- lib/modem.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/modem.js b/lib/modem.js index 25e4b3a..ba5ccb5 100644 --- a/lib/modem.js +++ b/lib/modem.js @@ -44,6 +44,9 @@ var defaultOpts = function() { if (process.env.DOCKER_TLS_VERIFY === '1' || opts.port === '2376') { opts.protocol = 'https'; + } else if (host.protocol === 'ssh:') { + opts.protocol = 'ssh'; + opts.username = host.username; } else { opts.protocol = 'http'; } @@ -71,6 +74,7 @@ var Modem = function(options) { this.socketPath = opts.socketPath; this.host = opts.host; this.port = opts.port; + this.username = opts.username; this.version = opts.version; this.key = opts.key; this.cert = opts.cert; @@ -201,7 +205,7 @@ Modem.prototype.buildRequest = function(options, context, data, callback) { var connectionTimeoutTimer; var opts = self.protocol === 'ssh' ? Object.assign(options, { - agent: ssh({'host': self.host, 'port': self.port}), + agent: ssh({'host': self.host, 'port': self.port, 'username': self.username, 'agent': process.env.SSH_AUTH_SOCK}), protocol: 'http' }) : options;