Skip to content

Commit f383654

Browse files
authored
Merge pull request #108 from bwateratmsft/master
Accept username and agent for SSH
2 parents d75a96a + 3fb0bb5 commit f383654

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/modem.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ var defaultOpts = function() {
4444

4545
if (process.env.DOCKER_TLS_VERIFY === '1' || opts.port === '2376') {
4646
opts.protocol = 'https';
47+
} else if (host.protocol === 'ssh:') {
48+
opts.protocol = 'ssh';
49+
opts.username = host.username;
4750
} else {
4851
opts.protocol = 'http';
4952
}
@@ -71,6 +74,7 @@ var Modem = function(options) {
7174
this.socketPath = opts.socketPath;
7275
this.host = opts.host;
7376
this.port = opts.port;
77+
this.username = opts.username;
7478
this.version = opts.version;
7579
this.key = opts.key;
7680
this.cert = opts.cert;
@@ -201,8 +205,8 @@ Modem.prototype.buildRequest = function(options, context, data, callback) {
201205
var connectionTimeoutTimer;
202206

203207
var opts = self.protocol === 'ssh' ? Object.assign(options, {
204-
agent: ssh({'host': self.host, 'port': self.port}),
205-
protocol: 'http'
208+
agent: ssh({'host': self.host, 'port': self.port, 'username': self.username, 'agent': process.env.SSH_AUTH_SOCK}),
209+
protocol: 'http:'
206210
}) : options;
207211

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

0 commit comments

Comments
 (0)