Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Provide SSH key securely to the docker build #17

Closed
tlvenn opened this issue Mar 10, 2017 · 3 comments
Closed

Provide SSH key securely to the docker build #17

tlvenn opened this issue Mar 10, 2017 · 3 comments

Comments

@tlvenn
Copy link
Contributor

tlvenn commented Mar 10, 2017

Right now unless I am missing something, there is no easy or safe way to provide an ssh key to the docker build so that dependencies that are pulled with ssh would be resolved properly.

Reading on http://blog.cloud66.com/using-ssh-private-keys-securely-in-docker-build and how Habitus is solving this elegantly, I believe their solution is best and should be relatively simple to implement.

The idea is to open a web server on the docker network to expose the ssh key or any other secrets that the Dockerfile could fetch and once used, delete it, all in one transaction, leaving no trace behind whatsoever.

RUN wget -O ~/.ssh/id_rsa http://192.168.99.1:8080/secrets/file/id_rsa && mix do deps.get, deps.compile && rm ~/.ssh/id_rsa

We should also add github as an known host automatically:

# Adding github to known hosts
RUN mkdir ~/.ssh && ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

What do you think @teamon ?

@teamon
Copy link
Contributor

teamon commented Mar 10, 2017

TBH I think this is out of scope of this project. I can't even imagine how it could be implemented in a generic way. Sooner or later you will want to use a custom Dockerfiles where you can do whatever you need :)

@tlvenn
Copy link
Contributor Author

tlvenn commented Mar 10, 2017

I should be fairly simple. We could expose in a configurable way any file over http like Habitus is doing. Starting a webserver using Plug when the mix task build is launched should not be so hard.

Something like:

config :mix_docker,
  secrets: identity: "~/.ssh/id_rsa.pub"

Then in your Dockerfile, you could do:

RUN wget -O ~/.ssh/id_rsa http://192.168.99.1:8080/identity && mix do deps.get, deps.compile && rm ~/.ssh/id_rsa

It's impossible to address this issue with a custom Dockerfile alone, you need to be able to serve over http what you want to share if you want to make sure you do it in a clean way.

I agree that people will most probably want to customize their Dockerfile. What i am proposing is to let them expose files they have locally over http so that it can be consumed by docker build.

And maybe we dont do something generic but only addressing the core issue of passing your ssh key.

Btw, how do you deal with this at Recruitee ?

@teamon
Copy link
Contributor

teamon commented Apr 4, 2017

Closing this in favour of #18

@teamon teamon closed this as completed Apr 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants