From 4e051c437e5d5976847db90ea79e9a870b834022 Mon Sep 17 00:00:00 2001 From: fidgetingbits Date: Mon, 20 May 2024 21:42:53 +0800 Subject: [PATCH] Don't fail if .ssh/authorized_keys is missing --- src/nixos-anywhere.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nixos-anywhere.sh b/src/nixos-anywhere.sh index adb04ae2..52367bb7 100755 --- a/src/nixos-anywhere.sh +++ b/src/nixos-anywhere.sh @@ -419,7 +419,8 @@ fi # Installation will fail if non-root user is used for installer. # Switch to root user by copying authorized_keys. if [[ ${is_installer-n} == "y" ]] && [[ ${ssh_user} != "root" ]]; then - ssh_ "${maybe_sudo} mkdir -p /root/.ssh; ${maybe_sudo} cp ~/.ssh/authorized_keys /root/.ssh" + # Allow copy to fail if authorized_keys does not exist, like if using /etc/ssh/authorized_keys.d/ + ssh_ "${maybe_sudo} mkdir -p /root/.ssh; ${maybe_sudo} cp ~/.ssh/authorized_keys /root/.ssh || true" ssh_connection="root@${ssh_host}" fi