apocas / docker-modem

Docker Remote API network stack driver.
Apache License 2.0
234 stars 112 forks source link

User is ignored in an SSH DOCKER_HOST #107

Closed bwateratmsft closed 5 years ago

bwateratmsft commented 5 years ago

Due to a combination of defaultOpts (https://github.com/apocas/docker-modem/blob/master/lib/modem.js#L16) and this line, any value passed in as the user in DOCKER_HOST would be ignored. I believe the behavior would be that the current user is used. There's a high chance that won't work, however--if the local username is not the same as the SSH username.

Ideally we should alter defaultOpts to permit things like ssh://user@host

bwateratmsft commented 5 years ago

I noticed an additional problem. It isn't possible to pass the agent either, so ssh-agent-based auth (which is the only option that can actually work with Docker) doesn't work.

bwateratmsft commented 5 years ago

@apocas I noticed in https://github.com/apocas/docker-modem/commit/8937fc48f294ee74a18b9b936369068e98c5e3e0 you removed the ssh config object passed through above; what was the reason behind that? We'd have to add it back, or something similar, in order to support passing in the agent.

apocas commented 5 years ago

You should be able to pass an "agent" to the Modem. https://github.com/apocas/docker-modem/blob/master/lib/modem.js#L81

I simplified it, by using the already existing "host" and "port" from Modem's constructor. https://github.com/apocas/docker-modem/blob/master/lib/modem.js#L72

bwateratmsft commented 5 years ago

@apocas I see that now. We can pass agent through dockerode to docker-modem. Ideally docker-modem would support that via DOCKER_HOST and SSH_AUTH_SOCK env vars, which is roughly what the Docker CLI does as well. I created #108