@@ -65,7 +65,7 @@ mkdir -p "$sshKeyDir"
65
65
declare -A diskEncryptionKeys=()
66
66
declare -A extraFilesOwnership=()
67
67
declare -a nixCopyOptions=()
68
- declare -a sshArgs=()
68
+ declare -a sshArgs=(" -o " " IdentitiesOnly=yes " " -i " " $sshKeyDir /nixos-anywhere " " -o " " UserKnownHostsFile=/dev/null " " -o " " StrictHostKeyChecking=no " )
69
69
70
70
showUsage () {
71
71
cat << USAGE
@@ -407,23 +407,27 @@ parseArgs() {
407
407
408
408
# ssh wrapper
409
409
runSshNoTty () {
410
- ssh -i " $sshKeyDir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " ${sshArgs[@]} " " $sshConnection " " $@ "
410
+ # shellcheck disable=SC2029
411
+ # We want to expand "$@" to get the command to run over SSH
412
+ ssh " ${sshArgs[@]} " " $sshConnection " " $@ "
411
413
}
412
414
runSshTimeout () {
413
- timeout 10 ssh -i " $sshKeyDir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " ${sshArgs[@]} " " $sshConnection " " $@ "
415
+ timeout 10 ssh " ${sshArgs[@]} " " $sshConnection " " $@ "
414
416
}
415
417
runSsh () {
416
- ssh " $sshTtyParam " -i " $sshKeyDir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " ${sshArgs[@]} " " $sshConnection " " $@ "
418
+ # shellcheck disable=SC2029
419
+ # We want to expand "$@" to get the command to run over SSH
420
+ ssh " $sshTtyParam " " ${sshArgs[@]} " " $sshConnection " " $@ "
417
421
}
418
422
419
423
nixCopy () {
420
- NIX_SSHOPTS=" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $sshKeyDir /nixos-anywhere ${sshArgs[*]} " nix copy \
424
+ NIX_SSHOPTS=" ${sshArgs[*]} " nix copy \
421
425
" ${nixOptions[@]} " \
422
426
" ${nixCopyOptions[@]} " \
423
427
" $@ "
424
428
}
425
429
nixBuild () {
426
- NIX_SSHOPTS=" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $sshKeyDir /nixos-anywhere ${sshArgs[*]} " nix build \
430
+ NIX_SSHOPTS=" ${sshArgs[*]} " nix build \
427
431
--print-out-paths \
428
432
--no-link \
429
433
" ${nixBuildFlags[@]} " \
@@ -470,32 +474,21 @@ uploadSshKey() {
470
474
ssh-keygen -t ed25519 -f " $sshKeyDir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
471
475
fi
472
476
473
- declare -a sshCopyIdArgs
474
- if [[ -n ${sshPrivateKeyFile} ]]; then
475
- unset SSH_AUTH_SOCK # don't use system agent if key was supplied
476
- sshCopyIdArgs+=(-o " IdentityFile=${sshPrivateKeyFile} " -f)
477
- fi
478
-
479
477
step Uploading install SSH keys
480
478
until
481
479
if [[ ${envPassword} == y ]]; then
482
480
sshpass -e \
483
481
ssh-copy-id \
484
- -i " $sshKeyDir " /nixos-anywhere.pub \
485
482
-o ConnectTimeout=10 \
486
- -o UserKnownHostsFile=/dev/null \
487
- -o IdentitiesOnly=yes \
488
- -o StrictHostKeyChecking=no \
489
- " ${sshCopyIdArgs[@]} " \
490
483
" ${sshArgs[@]} " \
491
484
" $sshConnection "
492
485
else
486
+ # To override `IdentitiesOnly=yes` set in `sshArgs` we need to set
487
+ # `IdentitiesOnly=no` first as the first time an SSH option is
488
+ # specified on the command line takes precedence
493
489
ssh-copy-id \
494
- -i " $sshKeyDir " /nixos-anywhere.pub \
490
+ -o IdentitiesOnly=no \
495
491
-o ConnectTimeout=10 \
496
- -o UserKnownHostsFile=/dev/null \
497
- -o StrictHostKeyChecking=no \
498
- " ${sshCopyIdArgs[@]} " \
499
492
" ${sshArgs[@]} " \
500
493
" $sshConnection "
501
494
fi
@@ -559,7 +552,7 @@ checkBuildLocally() {
559
552
-L \
560
553
" ${nixOptions[@]} " \
561
554
--expr \
562
- " derivation { system = \" $system \" ; name = \" env-$entropy \" ; builder = \" /bin/sh\" ; args = [ \" -c\" \" echo > \$ out\" ]; }" ; then
555
+ " derivation { system = \" $machineSystem \" ; name = \" env-$entropy \" ; builder = \" /bin/sh\" ; args = [ \" -c\" \" echo > \$ out\" ]; }" ; then
563
556
# The local build failed
564
557
buildOn=local
565
558
return
0 commit comments