@@ -11,6 +11,10 @@ Options:
11
11
set the flake to install the system from.
12
12
* -i <identity_file>
13
13
selects which SSH private key file to use.
14
+ * -p, --ssh-port <ssh_port>
15
+ set the ssh port to connect with
16
+ * --ssh-option <ssh_option>
17
+ set an ssh option
14
18
* -L, --print-build-logs
15
19
print full build logs
16
20
* -s, --store-paths <disko-script> <nixos-system>
@@ -23,6 +27,8 @@ Options:
23
27
do not reboot after installation, allowing further customization of the target installation.
24
28
* --kexec <url>
25
29
use another kexec tarball to bootstrap NixOS
30
+ * --post-kexec-ssh-port <ssh_port>
31
+ after kexec is executed, use a custom ssh port to connect. Defaults to 22
26
32
* --stop-after-disko
27
33
exit after disko formating, you can then proceed to install manually or some other way
28
34
* --extra-files <file...>
@@ -63,10 +69,12 @@ nix_options=(
63
69
substitute_on_destination=y
64
70
ssh_private_key_file=
65
71
ssh_tty_param=" -T"
72
+ post_kexec_ssh_port=22
66
73
67
74
declare -A disk_encryption_keys
68
75
declare -a nix_copy_options
69
76
declare -a ssh_copy_id_args
77
+ declare -a ssh_args
70
78
71
79
while [[ $# -gt 0 ]]; do
72
80
case " $1 " in
@@ -78,6 +86,14 @@ while [[ $# -gt 0 ]]; do
78
86
ssh_private_key_file=$2
79
87
shift
80
88
;;
89
+ -p | --ssh-port)
90
+ ssh_args+=(" -p" " $2 " )
91
+ shift
92
+ ;;
93
+ --ssh-option)
94
+ ssh_args+=(" -o" " $2 " )
95
+ shift
96
+ ;;
81
97
-L | --print-build-logs)
82
98
print_build_logs=y
83
99
;;
@@ -98,6 +114,10 @@ while [[ $# -gt 0 ]]; do
98
114
kexec_url=$2
99
115
shift
100
116
;;
117
+ --post-kexec-ssh-port)
118
+ post_kexec_ssh_port=$2
119
+ shift
120
+ ;;
101
121
--debug)
102
122
enable_debug=" -x"
103
123
print_build_logs=y
158
178
159
179
# ssh wrapper
160
180
timeout_ssh_ () {
161
- timeout 10 ssh -i " $ssh_key_dir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " $ssh_connection " " $@ "
181
+ timeout 10 ssh -i " $ssh_key_dir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " ${ssh_args[@]} " " $ ssh_connection" " $@ "
162
182
}
163
183
ssh_ () {
164
- ssh " $ssh_tty_param " -i " $ssh_key_dir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " $ssh_connection " " $@ "
184
+ ssh " $ssh_tty_param " -i " $ssh_key_dir " /nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " ${ssh_args[@]} " " $ ssh_connection" " $@ "
165
185
}
166
186
167
187
nix_copy () {
@@ -242,6 +262,7 @@ until
242
262
-o UserKnownHostsFile=/dev/null \
243
263
-o StrictHostKeyChecking=no \
244
264
" ${ssh_copy_id_args[@]} " \
265
+ " ${ssh_args[@]} " \
245
266
" $ssh_connection "
246
267
do
247
268
sleep 3
@@ -327,13 +348,21 @@ SSH
327
348
TMPDIR=/root/kexec setsid ${maybe_sudo} /root/kexec/kexec/run
328
349
SSH
329
350
330
- # wait for machine to become unreachable
351
+ # use the default SSH port to connect at this point
352
+ for i in " ${! ssh_args[@]} " ; do
353
+ if [[ ${ssh_args[i]} == " -p" ]]; then
354
+ ssh_args[i + 1]=$post_kexec_ssh_port
355
+ break
356
+ fi
357
+ done
358
+
359
+ # wait for machine to become unreachable.
331
360
while timeout_ssh_ -- exit 0; do sleep 1; done
332
361
333
362
# After kexec we explicitly set the user to root@
334
363
ssh_connection=" root@${ssh_host} "
335
364
336
- # watiting for machine to become available again
365
+ # waiting for machine to become available again
337
366
until ssh_ -o ConnectTimeout=10 -- exit 0; do sleep 5; done
338
367
fi
339
368
for path in " ${! disk_encryption_keys[@]} " ; do
@@ -400,7 +429,7 @@ nohup bash -c '${maybe_reboot}' >/dev/null &
400
429
SSH
401
430
402
431
if [[ -n ${maybe_reboot} ]]; then
403
- step Waiting for the maching to become reachable again
432
+ step Waiting for the machine to become reachable again
404
433
while timeout_ssh_ -- exit 0; do sleep 1; done
405
434
fi
406
435
0 commit comments