Skip to content

Commit 197343e

Browse files
Mic92Qubasa
andcommitted
Fix logging in as incorrect user if phases kexec is not set
When executing nixos-anywhere --phases disko myuser@<ip> for example we must assume that kexec has already been run and that the target user changed to root now. This will force nixos-anywhere to log in as root user if the kexec phase is not present. Co-authored-by: Qubasa <consulting@qube.email>
1 parent c84d6e0 commit 197343e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/nixos-anywhere.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,12 @@ main() {
10161016
sshUser=$(echo "$sshSettings" | awk '/^user / { print $2 }')
10171017
sshHost="${sshConnection//*@/}"
10181018
1019+
# If kexec phase is not present, we assume kexec has already been run
1020+
# and change the user to root@<sshHost> for the rest of the script.
1021+
if [[ ${phases[kexec]} != 1 ]]; then
1022+
sshConnection="root@${sshHost}"
1023+
fi
1024+
10191025
uploadSshKey
10201026
10211027
importFacts

0 commit comments

Comments
 (0)