Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default ssh port configurable #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the default port is already 22, why fallback to setting this variable to 22? If you do this, the -n condition will not be true and you'll modify the default sshd_config even if there's no change necessary. Then users will be bugged about conffile changes any time sshd_config changes in the debian package.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change to export SSH_PORT


export LOCALE_DEFAULT="${LOCALE_DEFAULT:-en_GB.UTF-8}"

Expand Down
4 changes: 4 additions & 0 deletions stage2/01-sys-tweaks/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down