Don't fail if .ssh/authorized_keys is missing

This commit is contained in:
fidgetingbits 2024-05-20 21:42:53 +08:00 committed by mergify[bot]
parent 242444d228
commit 3f975977d9

View File

@ -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