Allow the user to use keys that aren't in .ssh

Anton pointed out in the Detective customer zero feedback that some users may need to use private keys that aren't located in the usual ~/.ssh. We also got some feedback that the convention of asking for a key name instead of a key path was a bit confusing.

This MR allows the user to specify a full path to a key instead of just a name. The old behaviour still works if the user does have a key in ~/.ssh and they want to just specify the name.

Ansible-runner always mounts the user's ~/.ssh, which makes it basically "free" to ask for a key name instead of a path. Now we check if the user specified a path instead of a name, and then we resolve the path and mount the key into /root/.ssh in the container so that we can continue as usual.

I also added some more robust checks for the provided SSH key (whether or not it even exists, and calling ssh-keygen to ensure it's actually a private key). We resolve the path as well in an attempt to avoid path traversal attacks.

Fixes #194 (closed)

Merge request reports

Loading
Loading