Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept username and agent for SSH #108

Merged
merged 3 commits into from
Oct 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got errors without the : on the end of http, hence added it here.

}) : options;

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