diff --git a/README.md b/README.md index b630f2c..349c0bd 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ SSH_GROUP|Group name used for our SSH user.|`tunnelgroup` SSH_HOST_KEY_DIR|Location of where the SSH host keys should be stored.|`/etc/ssh/ssh_host_keys/` SSH_PORT|Listening port for SSH server (on container only. You'll still need to publish this port).|`2222` SSH_USER|Username for the SSH user that other users will connect into as.|`tunnel` +SSH_GATEWAYPORTS|Setting for the GatewayPorts sshd_config for reverse tunnelling|`no` ### 1. Set your `AUTHORIZED_KEYS` environment variable or provide a `/authorized_keys` file diff --git a/src/Dockerfile b/src/Dockerfile index 22631f4..5702da2 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -12,7 +12,8 @@ ENV ALLOWED_IPS="AllowUsers tunnel" \ PUID=9999 \ SSH_HOST_KEY_DIR="/etc/ssh/ssh_host_keys" \ SSH_PORT="2222" \ - SSH_USER="tunnel" + SSH_USER="tunnel" \ + SSH_GATEWAYPORTS="no" ARG PACKAGE_DEPENDENCIES="openssh-server,iputils-ping,locales,tini" \ REPOSITORY_BUILD_VERSION="dev" diff --git a/src/rootfs/entrypoint.sh b/src/rootfs/entrypoint.sh index 58620a4..f139b67 100644 --- a/src/rootfs/entrypoint.sh +++ b/src/rootfs/entrypoint.sh @@ -7,6 +7,7 @@ ssh_user=${SSH_USER:-"${default_unprivileged_user}"} ssh_host_key_dir=${SSH_HOST_KEY_DIR:-"/etc/ssh/ssh_host_keys"} ssh_user_home="/home/${ssh_user}" ssh_port=${SSH_PORT:-"2222"} +gatewayports=${SSH_GATEWAYPORTS:-"no"} if [ "$DEBUG" = "true" ]; then @@ -31,6 +32,17 @@ validate_allowed_ips() { fi } +validate_gateway_ports() { + case "$1" in + yes|no|clientspecified) ;; + *) + echo "🚨🚨🚨 CONFIGURATION ERROR:" + echo "SSH_GATEWAYPORTS must be set to \"yes\", \"no\", or \"clientspecified\"." + exit 1 + ;; + esac +} + ###################################################### # Main ###################################################### @@ -85,6 +97,7 @@ if { [ ! -z "${PUID}" ] && [ "${PUID}" != "$default_uid" ]; } || { [ ! -z "${PGI fi # Set SSHD configuration +validate_gateway_ports "${gatewayports}" echo "🤖 Setting SSHD configuration..." { echo "Port ${ssh_port}" @@ -119,6 +132,7 @@ echo "🤖 Setting SSHD configuration..." echo "MaxStartups 10:30:100" echo "ClientAliveInterval 300" echo "ClientAliveCountMax 2" + echo "GatewayPorts ${gatewayports}" } > /etc/ssh/sshd_config.d/custom.conf if [ "$DEBUG" = "true" ]; then