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

terraform: allow nixos-rebuild to use specified private key for deployment #78

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

jfroche
Copy link
Contributor

@jfroche jfroche commented Mar 21, 2023

nixos-rebuild/deploy.sh script enable ssh authentication with a given private key through the SSH_KEY environment variable.

Add additional variable for the private key used for the deployment.
To encourage the use of ssh-agent and discourage the storage of deployment keys in the terraform state we do not set the install ssh key as the default for the deployment key.

@jfroche jfroche requested review from Mic92 and Lassulus March 21, 2023 08:15
terraform/all-in-one/main.tf Outdated Show resolved Hide resolved
@jfroche jfroche force-pushed the feat/use-privatekey-for-rebuild branch from 620ef74 to 67a9470 Compare March 27, 2023 08:59
@jfroche jfroche requested a review from Mic92 March 27, 2023 09:01
…yment

`nixos-rebuild/deploy.sh` script enable ssh authentication with a given private key
through the `SSH_KEY` environment variable.

Add additional variable for the private key used for the deployment.
To encourage the use of ssh-agent and discourage the storage of deployment keys in the terraform state
we do not set the install ssh key as the default for the deployment key.

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
@jfroche jfroche force-pushed the feat/use-privatekey-for-rebuild branch from 6dffcac to 16143cd Compare March 27, 2023 22:29
variable "ssh_private_key" {
type = string
description = "Content of private key used to connect to the target_host. If set to - no key is passed to openssh and ssh will back to its own configuration"
default = "-"
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why the dash is needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@srounce srounce Mar 29, 2023

Choose a reason for hiding this comment

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

What is the "-" check for though?

Copy link
Contributor

@Lassulus Lassulus Mar 29, 2023

Choose a reason for hiding this comment

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

because not setting the value is more complicated in terraform than setting a dummy value which basically means: "no value"

@srounce
Copy link
Contributor

srounce commented Mar 29, 2023

Have just run this with install_user/install_ssh_key set and target_user/deployment_ssh_key left unset. Can confirm this case works as expected.

@Lassulus
Copy link
Contributor

bors merge

@bors bors bot merged commit ee5c39f into main Mar 29, 2023
@bors bors bot deleted the feat/use-privatekey-for-rebuild branch March 29, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants