-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: Add SSHKeyGen Step from SDK #96
Conversation
This makes use of the SSH communicators temporary key generation The builders already referenced "StepCleanupTempKeys" but since none were created it did nothing
Hi @LIV2 👋 - Could you please submit an enhancement request so that this pull request can be tracked back to the use case? From the README:
Thanks! Ryan Johnson |
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.
Thanks for opening up this change @LIV2. Our focus has been on updating Packer core mainly around HCL2, the go-cty bug, and plugin integration docs so I wasn't able to get to this PR. I think this is a nice change that folks can benefit from. The example documentation is a nice touch. Before merging I will make a small change to only generate the SSHKey if using the "ssh" communicator, as opposed to always generating an SSK key.
@@ -120,6 +120,10 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) | |||
&vmwcommon.StepSuppressMessages{}, | |||
&vmwcommon.StepHTTPIPDiscover{}, | |||
commonsteps.HTTPServerFromHTTPConfig(&b.config.HTTPConfig), | |||
&communicator.StepSSHKeyGen{ |
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.
We should only call StepSSHKeyGen if the configured communicator is "ssh" otherwise a SSH key will get generated when using winrm or no communicator at all. Which might be confusing.
&communicator.StepSSHKeyGen{ | |
multistep.If(b.config.Comm.Type == "ssh", &communicator.StepSSHKeyGen{ |
This change adds the SSHKeyGen step from the SDK.
This step will generate a temporary ssh keypair when there is no ssh password and no ssh key configured.
The code already includes the "StepCleanupTempKeys" step which I believe does nothing without the SSHKeyGen step anyway.
Also included is the ability to use the
SSHPublicKey
variable inside the boot command, I copied this from the VirtualBox builder.Closes #102