-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
add var.ssh_options to pass additional SSH options to nixos-rebuild #427
base: main
Are you sure you want to change the base?
Conversation
terraform/nixos-rebuild/deploy.sh
Outdated
sshOpts+=(-o StrictHostKeyChecking=no) | ||
sshConfigFile="$workDir/ssh_config" | ||
cat >"$sshConfigFile" <<EOF | ||
Host $TARGET_HOST |
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.
Yes. As you have rightfully said, this will be an issue for users configuring private ssh keys and jump hosts in their ssh_config.
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.
Here is a workaround for you specifically, could you not pass in -F in your case instead? terraform also allows to write files, no?
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.
Maybe we can add support for passing in an ssh config file?
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.
Here is a workaround for you specifically, could you not pass in -F in your case instead? terraform also allows to write files, no?
Yes this would work too. I changed the PR so that additional options are passed as a string to NIX_SSHOPTS
Maybe we can add support for passing in an ssh config file?
I think passing flags is more flexible. As you suggested we can pass -F
if a config file is needed
sshOpts+=(-o UserKnownHostsFile=/dev/null) | ||
sshOpts+=(-o StrictHostKeyChecking=no) |
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.
This changes the current behavior in nixos-anywhere, if you are not using terraform.
I think this one will solve your quoting issues btw: NixOS/nix#12020 |
I'm also interested by this change since it can also cover another usecase 👇🏻 I'm using passwordless sudo with
|
This PR adds a Terraform input variable named
ssh_options
to nixos-rebuild (and to the rebuild part of nixos-anywhere)The problem I'm trying to solve is being able to use
gcloud compute ssh
to rebuild NixOS.gcloud compute ssh
is a wrapper aroundssh
that sets a bunch of ssh options to connect to a GCP VM, even if there is no direct connection to it.Example usage:
I'm using a file to pass the SSH options because of this bug in Nix: NixOS/nix#5181. The content of NIX_SSHOPTS is passed to this tokenizer which splits by spaces and doesn't take quoted substrings into account.
This means that something like
NIX_SSHOPTS='-o ProxyCommand="my-ssh-command foo bar"'
wont't work unless the tokenizer is changed upstream.The disadvantage of passing options as a file is that it will break the terraform module for people relying on their
.ssh/config
, unless they copy the ssh options from.ssh/config
to the terraform module. I understand this might be too much of a downside and we might want to change the tokenizer instead.