diff --git a/quests/.includes/sshd_config b/quests/.includes/sshd_config index 66de021..0cf7758 100644 --- a/quests/.includes/sshd_config +++ b/quests/.includes/sshd_config @@ -37,7 +37,7 @@ Include /etc/ssh/sshd_config.d/*.conf PubkeyAuthentication yes # Expect .ssh/authorized_keys2 to be disregarded by default in future. -#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 +AuthorizedKeysFile /etc/ssh/authorized_keys/%u #AuthorizedPrincipalsFile none diff --git a/quests/Dockerfile b/quests/Dockerfile index 008533d..cffeadb 100644 --- a/quests/Dockerfile +++ b/quests/Dockerfile @@ -22,6 +22,8 @@ ENV NODE_PATH=/usr/src/node_modules COPY ./packages/container /usr/local/lib/container COPY ./quests/.includes/zshrc /etc/zsh/zshrc RUN rm -f /etc/motd /etc/issue /etc/issue.net /etc/update-motd.d/* +RUN rm -rf /etc/skel && mkdir -p /etc/skel +RUN mkdir -p /etc/ssh/authorized_keys && chmod 755 /etc/ssh/authorized_keys COPY ./quests/.includes/sshd_config /etc/ssh/sshd_config EXPOSE 22 diff --git a/quests/entrypoint.sh b/quests/entrypoint.sh index 505b5b2..78d14fc 100644 --- a/quests/entrypoint.sh +++ b/quests/entrypoint.sh @@ -5,13 +5,12 @@ USERNAME=commander if ! id -u ${USERNAME} >/dev/null 2>&1; then adduser --disabled-password --gecos '' --shell /bin/zsh ${USERNAME} && \ find / -name ".gitkeep" -type f -exec rm -f {} + - mkdir -p /home/${USERNAME}/.ssh && \ - cp /ssh_key.pub /home/${USERNAME}/.ssh/authorized_keys && \ - chmod 600 /home/${USERNAME}/.ssh/authorized_keys && \ - chmod 700 /home/${USERNAME}/.ssh && \ - chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.ssh + + PUB_KEY=/etc/ssh/authorized_keys/${USERNAME} + cp /ssh_key.pub ${PUB_KEY} + chmod 644 ${PUB_KEY} fi -mkdir /run/sshd +mkdir -p /run/sshd echo "Starting SSH server" /usr/sbin/sshd -D -e