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;