-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Verify SSH host key in remote-exec provisioner #17269
Comments
Hi @jcassee, Thanks for opening the issue! Sorry to keep you hanging here. I have some patches in the works to resurrect host key verification, and we should be able to get this missing feature in for an upcoming release. |
No problem, @jbardin. Great to see your pull request. One thing I am worried about is getting a known hostkey on the system. The only easy way I see is using |
What is the security risk of the SSH public key being printed on the console or saved in terraform state? If I had to choose between having the server's public key known (to attackers) vs not authenticating the server you are talking two - I know which one I'd prefer. |
The provisioned host requires both a public and corresponding private host key. So uploading one through Alternatively, you need to get the public key to Terraform after it was generated, but I don't know any method of doing so without using some central location (and how to authenticate the new host to that location?). |
I see. Thanks for the explanation and clearing up my misunderstanding. 👍 |
Hi @jcassee, Yes, getting the credentials onto the host to be provisioned is entirely an orthogonal issue, and not one that Terraform will directly handle. Besides user_data, which has the drawbacks you mentioned, you could also bake it into the AMI, or have the host pull the key pair from a secure location. The scenario I prefer is to have the new host create its own keys like usual, then contact a signing service (e.g. the Vault ssh host signer) to sign its public key during initialization. I mentioned it in the PR, but the provisioner is still somewhat limited when using signed keys, because the connection is made to the IP address by default (at least I think most providers send just the IP address), so the authority needs to be set on the IP address. If the authority is for a host or domain, the provisioner will need to be delegated to a null_resource to pass in the correct name. |
Sounds good, @jbardin. It's certainly something I can work with. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Expected Behavior
It would be nice to be able to tell Terraform that the droplet has a known SSH hostkey, Cloud-init's
write_files
could be used to upload a SSH hostkey certificate too. In that case Terraform could be told to verify the certificate.References
The text was updated successfully, but these errors were encountered: