Skip to content

Commit 33c3f6b

Browse files
committed
2026-05-09
1 parent 7abb8b2 commit 33c3f6b

3 files changed

Lines changed: 44 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 2026-05-09
4+
- Switch base image from Alpine 3.18 to `debian:stable-slim`
5+
- Replace Alpine setup commands with Debian equivalents and expand installed packages
6+
- Harden `sshd_config` defaults (auth/session limits, forwarding, keepalive, login grace)
7+
- Update `bin/demyx-sudo` host key logic to handle `rsa`, `ecdsa`, and `ed25519` keys with bidirectional sync and key generation fallback
8+
39
## 2025-07-28
410
- Update GitHub Actions workflow to use run ID in commit message for scheduled builds [3da220a](https://github.com/demyxsh/ssh/commit/3da220a894a17b10399f491bcb9f05e7086c5a46)
511

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.18
1+
FROM debian:stable-slim
22

33
LABEL sh.demyx.image demyx/ssh
44
LABEL sh.demyx.maintainer Demyx <info@demyx.sh>
@@ -20,13 +20,14 @@ ENV SSH_ROOT "$DEMYX"
2020

2121
# Packages and setup
2222
RUN set -ex; \
23-
apk add --no-cache --update bash openssh sudo tzdata
23+
apt update; \
24+
apt install -y bash curl git htop nano openssh-client openssh-server sudo tzdata
2425

2526
# Configure Demyx
2627
RUN set -ex; \
2728
# Create demyx user
28-
addgroup -g 1000 -S demyx; \
29-
adduser -u 1000 -D -S -G demyx demyx; \
29+
groupadd -g 1000 demyx; \
30+
useradd -u 1000 -g demyx -m -s /bin/bash demyx; \
3031
\
3132
# Create demyx directories
3233
install -d -m 0755 -o demyx -g demyx "$DEMYX"; \
@@ -46,9 +47,17 @@ RUN set -ex; \
4647
sed -i "s|/home/demyx:/sbin/nologin|/home/demyx:/bin/bash|g" /etc/passwd; \
4748
sed -i "s|#Port 22|Port 2222|g" /etc/ssh/sshd_config; \
4849
sed -i "s|#PermitRootLogin prohibit-password|PermitRootLogin no|g" /etc/ssh/sshd_config; \
49-
sed -i "s|#PubkeyAuthentication|PubkeyAuthentication|g" /etc/ssh/sshd_config; \
50-
sed -i "s|#PasswordAuthentication|PasswordAuthentication|g" /etc/ssh/sshd_config; \
51-
sed -i "s|#PermitEmptyPasswords no|PermitEmptyPasswords no|g" /etc/ssh/sshd_config; \
50+
sed -i "s|#PubkeyAuthentication.*|PubkeyAuthentication no|g" /etc/ssh/sshd_config; \
51+
sed -i "s|#PasswordAuthentication.*|PasswordAuthentication yes|g" /etc/ssh/sshd_config; \
52+
sed -i "s|#PermitEmptyPasswords.*|PermitEmptyPasswords no|g" /etc/ssh/sshd_config; \
53+
sed -i "s|#LoginGraceTime 2m|LoginGraceTime 30|g" /etc/ssh/sshd_config; \
54+
sed -i "s|#MaxAuthTries 6|MaxAuthTries 3|g" /etc/ssh/sshd_config; \
55+
sed -i "s|#MaxSessions 10|MaxSessions 3|g" /etc/ssh/sshd_config; \
56+
sed -i "s|#X11Forwarding yes|X11Forwarding no|g" /etc/ssh/sshd_config; \
57+
sed -i "s|#AllowTcpForwarding yes|AllowTcpForwarding local|g" /etc/ssh/sshd_config; \
58+
sed -i "s|#PermitUserEnvironment no|PermitUserEnvironment no|g" /etc/ssh/sshd_config; \
59+
sed -i "s|#ClientAliveInterval 0|ClientAliveInterval 300|g" /etc/ssh/sshd_config; \
60+
sed -i "s|#ClientAliveCountMax 3|ClientAliveCountMax 0|g" /etc/ssh/sshd_config; \
5261
\
5362
# Configure sudo
5463
echo "demyx ALL=(ALL) NOPASSWD:SETENV: /usr/local/bin/demyx-sudo" > /etc/sudoers.d/demyx; \

bin/demyx-sudo

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,29 @@ demyx_sudo_permission() {
4747
DEMYX_SUDO_PERMISSION=/home/"$DEMYX_USERNAME"
4848

4949
# Prevents ssh errors from local machine
50-
if [[ -f "$DEMYX_SUDO_PERMISSION"/.ssh/ssh_host_rsa_key ]]; then
51-
if [[ ! -f /etc/ssh/ssh_host_rsa_key ]]; then
52-
cp "$DEMYX_SUDO_PERMISSION"/.ssh/ssh_host_rsa_key /etc/ssh
53-
fi
54-
if [[ ! -f /etc/ssh/ssh_host_rsa_key.pub ]]; then
55-
cp "$DEMYX_SUDO_PERMISSION"/.ssh/ssh_host_rsa_key.pub /etc/ssh
56-
fi
57-
else
58-
if [[ ! -f /etc/ssh/ssh_host_rsa_key ]]; then
59-
ssh-keygen -A >/dev/null
60-
fi
61-
if [[ ! -f "$DEMYX_SUDO_PERMISSION"/.ssh/ssh_host_rsa_key ]]; then
62-
cp /etc/ssh/ssh_host_rsa_key "$DEMYX_SUDO_PERMISSION"/.ssh
63-
fi
64-
if [[ ! -f "$DEMYX_SUDO_PERMISSION"/.ssh/ssh_host_rsa_key.pub ]]; then
65-
cp /etc/ssh/ssh_host_rsa_key.pub "$DEMYX_SUDO_PERMISSION"/.ssh
50+
local DEMYX_SSH_KEY_TYPE=
51+
for DEMYX_SSH_KEY_TYPE in rsa ecdsa ed25519; do
52+
local DEMYX_SSH_HOME_KEY=
53+
local DEMYX_SSH_ETC_KEY=
54+
DEMYX_SSH_HOME_KEY="$DEMYX_SUDO_PERMISSION"/.ssh/ssh_host_${DEMYX_SSH_KEY_TYPE}_key
55+
DEMYX_SSH_ETC_KEY=/etc/ssh/ssh_host_${DEMYX_SSH_KEY_TYPE}_key
56+
57+
if [[ -f "$DEMYX_SSH_HOME_KEY" ]]; then
58+
cp "$DEMYX_SSH_HOME_KEY" "$DEMYX_SSH_ETC_KEY"
59+
if [[ -f "$DEMYX_SSH_HOME_KEY".pub ]]; then
60+
cp "$DEMYX_SSH_HOME_KEY".pub "$DEMYX_SSH_ETC_KEY".pub
61+
fi
62+
elif [[ -f "$DEMYX_SSH_ETC_KEY" ]]; then
63+
cp "$DEMYX_SSH_ETC_KEY" "$DEMYX_SSH_HOME_KEY"
64+
if [[ -f "$DEMYX_SSH_ETC_KEY".pub ]]; then
65+
cp "$DEMYX_SSH_ETC_KEY".pub "$DEMYX_SSH_HOME_KEY".pub
66+
fi
67+
else
68+
ssh-keygen -t "$DEMYX_SSH_KEY_TYPE" -N '' -f "$DEMYX_SSH_ETC_KEY" >/dev/null
69+
cp "$DEMYX_SSH_ETC_KEY" "$DEMYX_SSH_HOME_KEY"
70+
cp "$DEMYX_SSH_ETC_KEY".pub "$DEMYX_SSH_HOME_KEY".pub
6671
fi
67-
fi
72+
done
6873

6974
if [[ -f "$DEMYX_SUDO_PERMISSION"/.ssh/authorized_keys ]]; then
7075
chmod 644 "$DEMYX_SUDO_PERMISSION"/.ssh/authorized_keys

0 commit comments

Comments
 (0)