Skip to content
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

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

LIV2
Copy link
Contributor

@LIV2 LIV2 commented Sep 20, 2022

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

This makes use of the SSH communicators temporary key generation

The builders already referenced "StepCleanupTempKeys" but since none were created it did nothing
@LIV2 LIV2 requested a review from a team as a code owner September 20, 2022 14:04
@tenthirtyam tenthirtyam changed the title Add SSHKeyGen Step from SDK feat: Add SSHKeyGen Step from SDK Sep 28, 2022
@tenthirtyam
Copy link
Collaborator

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:

"...In case of feature contribution, we kindly ask you to open an issue to discuss it beforehand."

Thanks!

Ryan Johnson
Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.

Copy link
Member

@nywilken nywilken left a 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{
Copy link
Member

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.

Suggested change
&communicator.StepSSHKeyGen{
multistep.If(b.config.Comm.Type == "ssh", &communicator.StepSSHKeyGen{

@nywilken nywilken merged commit 5cf0d88 into hashicorp:main Sep 12, 2023
@hashicorp hashicorp locked and limited conversation to collaborators Jun 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for SSHKeyGen step from SDK
3 participants