From f6a30c1a6d23ac11c4bc9b49f75e4e247d4347f2 Mon Sep 17 00:00:00 2001 From: Jeronimo Pellegrini Date: Wed, 4 Sep 2019 22:29:53 -0300 Subject: [PATCH] Make AllowedUsers configurable in sshd_config docker/root/usr/bin/entrypoint already allows for the specification of USER, USER_UID, USER_GID. But since AllowedUsers is hardcoded in sshd_config, one cannot log in as a user different ftom git. This change substitutes ${USER} for git in the sshd_config template. Signed-off-by: Jeronimo Pellegrini --- docker/root/etc/templates/sshd_config | 2 +- docker/root/usr/bin/entrypoint | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/root/etc/templates/sshd_config b/docker/root/etc/templates/sshd_config index ba92e236e171..bf0b936d7c09 100644 --- a/docker/root/etc/templates/sshd_config +++ b/docker/root/etc/templates/sshd_config @@ -25,7 +25,7 @@ ChallengeResponseAuthentication no PasswordAuthentication no PermitEmptyPasswords no -AllowUsers git +AllowUsers ${USER} Banner none Subsystem sftp /usr/lib/ssh/sftp-server diff --git a/docker/root/usr/bin/entrypoint b/docker/root/usr/bin/entrypoint index d8e68b9404d6..a3c03ecff379 100755 --- a/docker/root/usr/bin/entrypoint +++ b/docker/root/usr/bin/entrypoint @@ -3,8 +3,6 @@ if [ "${USER}" != "git" ]; then # rename user sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd - # switch sshd config to different user - sed -i -e "s/AllowUsers git$/AllowUsers ${USER}/g" /etc/ssh/sshd_config fi if [ -z "${USER_GID}" ]; then