-
Notifications
You must be signed in to change notification settings - Fork 257
Set SSH BatchMode=yes when cloning git over ssh #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@ryanuber The man page doesn't specify the behavior around known hosts, but I imagine it's something like:
This behavior is probably fine, but this is just a guess as to what the behavior is. My points of concern are:
|
|
@cbednarski everything would depend on the SSH client configuration. You could have it either fail or ignore on mismatch. You could have it /dev/null the known hosts file. I think what we would want to do is automatically accept unknown hosts, fail hard on mismatches, because we run every task in an isolated root. One thing I didn't think about was the Terraform CLI, where an unknown host today would result in a prompt, and users might be counting on that in some places, though I'm not sure. I think we can just convert this into a bugfix PR, and remove BatchMode, and just deferring all options to the SSH client config. That way there is no risk of regression in that sense. |
Ah that's an interesting idea. I guess the question I have is whether we want the user or operator to make this decision. On your laptop you are both so this is moot. However on a remote build host this becomes a bit more difficult to manage. Either:
I think 1 is obviously the secure option but it's difficult to manage this because there may be multiple hosts, or the host signature may change, and that requires manual intervention on the build machine. In my case I am a remote operator and so there is actually a third party who is running the machine but is not really responsible for configuring it (and thus does not have a direct means to edit the known_hosts file). There are obviously ways around this and we should probably not try to solve for them here, but this is on my mind. In the case of using HTTPS the host validation happens by way of a certificate authority and a root cert that is pre-installed on the machine. Via SSH we run into the age-old problem of host validation (did you really validate that host or did you just accept the fingerprint) so the BatchMode method is probably not a secure default anyway. So in this circumstance, it sounds like your proposal is to use option 1 to provide a secure default and punt on this code change. This makes sense to me, and it seems like the secure default with whitelisting or even auto-approval is already supported. The question I have is whether it makes sense to provide users with an escape hatch via e.g. I would also add that if the user does opt to disable SSL verification we probably should not poison the host by propagating that to other runs. For example if I want to automatically accept a cert for one run this should not be sticky to other runs that want to opt-out of auto-accept. I think this BatchMode change has other stateful side effects in this respect. |
|
I think we could explore an insecure flag, but the only weird thing is that you run into an options merge problem: Which settings win, the host's config or the client's preference? It gets harder to handle that nicely or predictably. I'd say let's just punt on this for now, fix the issues at hand by merging this PR, and go from there. |
|
Oops, missed your comment update. As for side effects, this is completely up to the service owner who uses go-getter. In our case, we throw away temp environments on each run, so they don't affect anything else. We do this in Nomad batch jobs (isolated by cgroups/namespaces) and during TF/Packer runs (isolated by a VM), so I don't think we would bump into any weird collisions there, and it is completely manageable from the service owner's perspective. |
Yeah, just curious what the path of least surprise is here if I pull down a terraform module, for example. This change LGTM, though. We can dial in the behavior we want with extra config but I feel better about the default behavior now. |
cbednarski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sets the
BatchMode=yesSSH option to prevent SSH from doing interactive prompts duringgit clone.This also refactors some of the SSH env var handling to match what we were already doing prior to the
?sshkeyfeature in #43, and fixes a bug where we didn't set up the SSH key during submodule fetches.