File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -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=(" -i" " $sshKeyDir /nixos-anywhere" " -o" " UserKnownHostsFile=/dev/null" " -o" " StrictHostKeyChecking=no" )
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
@@ -474,26 +474,21 @@ uploadSshKey() {
474
474
ssh-keygen -t ed25519 -f " $sshKeyDir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
475
475
fi
476
476
477
- declare -a sshCopyIdArgs
478
- if [[ -n ${sshPrivateKeyFile} ]]; then
479
- unset SSH_AUTH_SOCK # don't use system agent if key was supplied
480
- sshCopyIdArgs+=(-o " IdentityFile=${sshPrivateKeyFile} " -f)
481
- fi
482
-
483
477
step Uploading install SSH keys
484
478
until
485
479
if [[ ${envPassword} == y ]]; then
486
480
sshpass -e \
487
481
ssh-copy-id \
488
482
-o ConnectTimeout=10 \
489
- -o IdentitiesOnly=yes \
490
- " ${sshCopyIdArgs[@]} " \
491
483
" ${sshArgs[@]} " \
492
484
" $sshConnection "
493
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
494
489
ssh-copy-id \
490
+ -o IdentitiesOnly=no \
495
491
-o ConnectTimeout=10 \
496
- " ${sshCopyIdArgs[@]} " \
497
492
" ${sshArgs[@]} " \
498
493
" $sshConnection "
499
494
fi
You can’t perform that action at this time.
0 commit comments