Skip to content

option --copy-host-keys not working #598

@dearfl

Description

@dearfl

Prerequisites

  • I have updated to the latest version using nix run --refresh github:nix-community/nixos-anywhere
  • I have reproduced the issue with the --debug flag
  • I have searched existing issues to make sure this isn't a duplicate

Bug Description

Sorry I don't have the time to take all these steps to reproduce, anyway, it seems when --copy-host-keys not working, at least in my case.

I'm triyng to install a minimal NixOS on a 512MiB memory vultr vps, naturally I use the minimal NixOS ISO as the installation medium. I need copy the host keys for bootstrap vaultix(secrets) setup, however when the installation finished, the host keys on VPS is not what on my local machine, thus vaultix failed to decrypt my secrets.

I belive this should be the relevant code, however I can't really understand it.

if [ ${copyHostKeys-n} = "y" ]; then
# NB we copy host keys that are in turn copied by kexec installer.
mkdir -m 755 -p /mnt/etc/ssh
for p in /etc/ssh/ssh_host_*; do
# Skip if the source file does not exist (i.e. glob did not match any files)
# or the destination already exists (e.g. copied with --extra-files).
if [ ! -e "\$p" ] || [ -e "/mnt/\$p" ]; then
continue
fi
cp -a "\$p" "/mnt/\$p"
done
fi

Could it be only occur when using the minimal NixOS ISO? Since it not kexec?

Steps to Reproduce

I have my nixos config on https://github.com/dearfl/nyx, however I don't think it necessary to reproduce.

  1. deploy a vultr vps with a minimal NixOS ISO attached.
  2. install any nixosconfig with --copy-host-keys
  3. after the installation finish, you should see ssh-keyscan return a public key different from your local machine.

Debug Logs

https://fars.ee/cMYe

Command Used

nix run nixpkgs#nixos-anywhere -- -f .#vultr --build-on local --copy-host-keys --no-disko-deps --target-host root@207.148.71.76

Target System

Other

NixOS Version

No response

Environment Information

  • Host OS:
  • Nix version:
  • Target architecture:

Configuration Files

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions