Ask questionsCustom SSH Credentials
I can't rely on an ssh agent to provide a private key. Sometimes I need to provide a password, sometimes I need to manually load the key file. But the docker-py code only connects with this in SSHHTTPAdapter:
self.ssh_client.connect( parsed.hostname, parsed.port, parsed.username, )
There is no flexibility here. How am I supposed to connect with a custom key or password? I thought I might hack my way in by reassigning APIClient._custom_adapter to my own subclass of SSHHTTPAdapter, but then I realized the APIClient.__init__ is a huge mess that does way too much. That method would always raise an exception so I would also have to totally reimplement that method in a subclass. This is too much maintenance overhead for my deployment script that I would like to keep as simple as possible.
It should be exposed in SSHHTTPAdapter. I might even recommend doing both of these:
It should also be exposed somehow in APIClient.__init__, for example:
I'm happy to take the lead on this and submit a PR, but I would like to get some feedback first.
Answer questions shin-
You can already provide a custom password through the
base_url parameter, e.g.
ssh://user:firstname.lastname@example.org:22. For more advanced uses, you should be able to write your own
Adapter subclass and pass it to the
mount() (see the requests doc on that topic). For example,
ssh_adapter = MySSHAdapter(url, key_path) client = APIClient(base_url='ssh://bogus:22') client.mount('http+docker://ssh', ssh_adapter)
I think eventually we may want to have the option of passing a private key to the
Client instantiation in some form (TBD - maybe something similar to the
TLSConfig), but anything beyond that, like first-class adapter modularity, would probably be beyond the scope of what we're trying to do with the library.
Hope that helps!