diff --git a/lib/modem.js b/lib/modem.js index cd89dd0..c845911 100644 --- a/lib/modem.js +++ b/lib/modem.js @@ -47,6 +47,7 @@ var defaultOpts = function() { } else if (host.protocol === 'ssh:') { opts.protocol = 'ssh'; opts.username = host.username; + opts.sshAuthAgent = process.env.SSH_AUTH_SOCK; } else { opts.protocol = 'http'; } @@ -84,6 +85,7 @@ var Modem = function(options) { this.checkServerIdentity = opts.checkServerIdentity; this.agent = opts.agent; this.headers = opts.headers || {}; + this.sshAuthAgent = opts.sshAuthAgent; if (this.key && this.cert && this.ca) { this.protocol = 'https'; @@ -205,7 +207,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, 'username': self.username, 'agent': process.env.SSH_AUTH_SOCK}), + agent: ssh({'host': self.host, 'port': self.port, 'username': self.username, 'agent': self.sshAuthAgent}), protocol: 'http:' }) : options;