Allow the frontend to mount keys that are not in ~/.ssh
Anton made a great point in the customer 0 feedback issue about keys that aren't necessarily in ~/.ssh. Here's my comment copied here:
The SSH key convention makes sense now that you’ve explained it, but I wasn’t familiar with it - most scripts I’ve used that require SSH keys ask for the path rather than just the name. A hint in the prompt itself like
“Enter SSH private key name in your ~/.ssh directory (eg. id_ed25519)”might help others avoid the same confusion.That makes sense to me! We mention it in the README I think but it would be good to put it in the prompt itself. Thanks for the suggestion
Actually one other thought - does this mean we cannot use SSH private keys outside
~/.ssh? For GitLab Environment Toolkit, I typically have a separate SSH private key located in~/gitlab/get/keys.Hmm, I suppose you're right, actually. None of us on the development team regularly use keys outside
~/.sshso it never really came up, but I can definitely see that being a blocker for a lot of folks. I don't think it would be too difficult to adapt the frontend to be able to mount keys that're outside of.ssh.See, normally I'd like to use ssh-agent for this, but Docker on macOS is full of jank and has nothing but trouble trying to mount the ssh-agent socket in the container.
I wonder if it might be a better idea to use the full key path (which lines up better with the usual convention as a bonus) and then just mount the individual key if it lies outside of
~/.ssh. I don't think that's unreasonable and it'd kinda take care of two birds with one stone.
As I said in my comment, we can probably handle this like so:
- Allow the user to enter the full path to the key. We can keep the ability to just use a key filename in
~/.sshas well.- If the user does enter a full path, resolve it and mount it into the container.
- Continue as normal with the newly-mounted key
We will want to be careful here as the user can specify arbitrary paths. We should make sure we're not gonna cause any path traversal vulnerabilities and we should not allow the user to manipulate the mount path.
Thankfully this shouldn't be terribly difficult to actually implement, so I'll get an MR in shortly. Thank you for the suggestion @anton!