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

Always provide our known_hosts in addition to user known_hosts #1464

Merged
merged 3 commits into from
Nov 18, 2021

Conversation

roberth
Copy link
Member

@roberth roberth commented Aug 6, 2021

Solves one of the problems from #1264 (comment)

It also solves a problem where multiple deployments to distinct private networks fight over the key for the same ip that occurs in both.

nixops import --include-keys-like functionality doesn't seem to be included.

Prevously, you'd

  1. create a deployment
  2. upload the state
  3. download the deployment state on a fresh machine (eg colleague)
  4. nixops ssh doesn't know the keys
  5. non-interactive deployments fail

With this pr, we don't have to rely on user configuration to include
known_hosts entries for the deployments.

It makes nixops import --include-keys unnecessary, unless you
use those entries outside of nixops.

Since recently we can get our deployment state from remote storage
backends, but we didn't have a way to get configure the known_hosts
yet. This is now largely unnecessary.

This functionality requires some cooperation from the plugins. For
instance, here's what ec2 needs to do: (pun intended)

+    def get_ssh_host_keys(self):
+        return self.private_ipv4 + " " + self.public_host_key + "\n" + self.public_ipv4 + " " + self.public_host_key + "\n"

(NixOS/nixops-aws#141)

This way, we don't have to rely on user configuration to include
known_hosts entries for the deployments.

It makes `nixops import --include-keys` unnecessary, unless you
use those entries outside of nixops.

Since recently we can get our deployment state from remote storage
backends, but we didn't have a way to get configure the known_hosts
yet. This is now largely unnecessary.

This functionality requires some cooperation from the plugins. For
instance, here's what ec2 needs to do: (pun intended)

+    def get_ssh_host_keys(self):
+        return self.private_ipv4 + " " + self.public_host_key + "\n" + self.public_ipv4 + " " + self.public_host_key + "\n"
@roberth roberth force-pushed the internal-known-hosts-handling branch from ec0007f to 94a6884 Compare August 6, 2021 16:46
roberth added a commit to hercules-ci/nixops-aws that referenced this pull request Aug 6, 2021
@roberth roberth mentioned this pull request Aug 26, 2021
16 tasks
nixops/backends/__init__.py Outdated Show resolved Hide resolved
nixops/backends/__init__.py Outdated Show resolved Hide resolved
nixops/backends/__init__.py Outdated Show resolved Hide resolved
nixops/backends/__init__.py Outdated Show resolved Hide resolved
nixops/backends/__init__.py Outdated Show resolved Hide resolved
@roberth
Copy link
Member Author

roberth commented Aug 30, 2021

Thanks @Mic92 that was very helpful!

@roberth roberth merged commit 7ebdd8a into NixOS:master Nov 18, 2021
roberth added a commit to hercules-ci/nixops-gce that referenced this pull request Nov 18, 2021
This will let NixOps provide the host keys directly to the ssh
client, regardless of whether they've been saved to user dotfiles.

It solves a problem where the host keys were not known on systems
that retrieve the state from a remote state provider.

See NixOS/nixops#1464
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.

3 participants