Skip to content

Commit

Permalink
Support user from ssh://user@host, and agent from env
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft authored Oct 17, 2019
1 parent 927b11f commit 05f4319
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 05f4319

Please sign in to comment.