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

Allow specifying additional authorized_keys #23

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

LBGarber
Copy link
Contributor

Users are currently unable to provision Linode Instances with a predefined public or private key. If ssh_private_key_file is specified, the public key will always be set to nil and provisioning will fail.

This change allows users to set the authorized_keys field exposed by the Linode API, which allows for an Instance to be provisioned with any number of public keys.

For example:

source "linode" "example" {
  image             = "linode/alpine3.14"
  image_description = "My Alpine Image."
  image_label       = "packer-alpine"
  instance_label    = "temp-packer-alpine"
  instance_type     = "g6-nanode-1"
  linode_token      = var.linode_token
  region            = "us-east"

  authorized_keys = [chomp(file("/path/to/my/pubkey.pub"))]

  ssh_username      = "root"
  ssh_private_key_file = "/path/to/my/privkey"
}

I've also added a quick test to ensure the authorized_keys field is handled correctly.

Please let me know if you have any suggestions or more idiomatic solutions to this problem, especially if there is a preferred way to handle this with a communicator!

Thanks! 😄

Closes #18

@LBGarber LBGarber requested a review from a team as a code owner September 27, 2021 15:42
@LBGarber LBGarber force-pushed the add-authorized-keys branch 2 times, most recently from c82b0bb to eb65f6b Compare September 27, 2021 15:45
Copy link
Contributor

@azr azr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Image string `mapstructure:"image"`
SwapSize int `mapstructure:"swap_size"`
RootPass string `mapstructure:"root_pass"`
RootSSHKey string `mapstructure:"root_ssh_key"`
Copy link
Contributor

@azr azr Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this RootSSHKey field that was previously settable is technically a backwards incompatible change, but at the same time it's not documented nor used. So this looks okay to me.

@azr azr merged commit 20dec8e into linode:main Sep 28, 2021
@azr azr added technical-debt enhancement issues that request a enhancement and removed technical-debt labels Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement issues that request a enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting ssh_private_key_file fails with linode error
2 participants