Skip to content

Commit

Permalink
Merge pull request #108 from bwateratmsft/master
Browse files Browse the repository at this point in the history
Accept username and agent for SSH
  • Loading branch information
apocas authored Oct 17, 2019
2 parents d75a96a + 3fb0bb5 commit f383654
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions 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,8 +205,8 @@ 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}),
protocol: 'http'
agent: ssh({'host': self.host, 'port': self.port, 'username': self.username, 'agent': process.env.SSH_AUTH_SOCK}),
protocol: 'http:'
}) : options;

var req = http[self.protocol === 'ssh' ? 'http': self.protocol].request(opts, function() {});
Expand Down

0 comments on commit f383654

Please sign in to comment.