From cea1f723056271c9112b56433571b823cb019d5b Mon Sep 17 00:00:00 2001 From: KeithYeh Date: Wed, 11 Nov 2020 23:34:50 +0800 Subject: [PATCH 1/2] Make default ssh port configurable (#282) --- README.md | 2 ++ build.sh | 1 + stage2/01-sys-tweaks/01-run.sh | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 8b7f875af5..f867ca20b1 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,8 @@ The following environment variables are supported: public key authentication. Note that if SSH is not enabled this will take effect when SSH becomes enabled. + * `SSH_PORT` (Default: `22`) + * `STAGE_LIST` (Default: `stage*`) If set, then instead of working through the numeric stages in order, this list will be followed. For example setting to `"stage0 stage1 mystage stage2"` will run the contents of `mystage` before stage2. Note that quotes are needed around the list. An absolute or relative path can be given for stages outside the pi-gen directory. diff --git a/build.sh b/build.sh index 6f720b1f50..9d8fdd477e 100755 --- a/build.sh +++ b/build.sh @@ -172,6 +172,7 @@ export WPA_PASSWORD export WPA_COUNTRY export ENABLE_SSH="${ENABLE_SSH:-0}" export PUBKEY_ONLY_SSH="${PUBKEY_ONLY_SSH:-0}" +export SSH_PORT="${SSH_PORT:-22}" export LOCALE_DEFAULT="${LOCALE_DEFAULT:-en_GB.UTF-8}" diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index c1836f9ca6..4eb6eaf76c 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -23,6 +23,10 @@ if [ "${PUBKEY_ONLY_SSH}" = "1" ]; then s/^#?[[:blank:]]*PasswordAuthentication[[:blank:]]*yes[[:blank:]]*$/PasswordAuthentication no/' "${ROOTFS_DIR}"/etc/ssh/sshd_config fi +if [ -n "${SSH_PORT}" ]; then + sed -i "s/#Port 22/Port ${SSH_PORT}/" "${ROOTFS_DIR}/etc/ssh/sshd_config" +fi + on_chroot << EOF systemctl disable hwclock.sh systemctl disable nfs-common From b9216bfa07e33fd3f4e807d364c405d51b7a5c57 Mon Sep 17 00:00:00 2001 From: KeithYeh Date: Wed, 18 Nov 2020 14:50:30 +0800 Subject: [PATCH 2/2] Revise SSH_PORT default value --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9d8fdd477e..cf3196c81b 100755 --- a/build.sh +++ b/build.sh @@ -172,7 +172,7 @@ export WPA_PASSWORD export WPA_COUNTRY export ENABLE_SSH="${ENABLE_SSH:-0}" export PUBKEY_ONLY_SSH="${PUBKEY_ONLY_SSH:-0}" -export SSH_PORT="${SSH_PORT:-22}" +export SSH_PORT export LOCALE_DEFAULT="${LOCALE_DEFAULT:-en_GB.UTF-8}"