Created
August 29, 2017 13:10
-
-
Save duzun/9c3702ae874cb7193f9062a20ccfd74f to your computer and use it in GitHub Desktop.
SSHD for Alpine container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM httpd:2.4-alpine | |
# SSHD ################################# | |
RUN apk update && \ | |
apk add openssh augeas && \ | |
mkdir -p ~root/.ssh /etc/authorized_keys && chmod 700 ~root/.ssh/ && \ | |
augtool 'set /files/etc/ssh/sshd_config/AuthorizedKeysFile ".ssh/authorized_keys /etc/authorized_keys/%u"' && \ | |
augtool 'set /files/etc/ssh/sshd_config/PermitRootLogin yes' && \ | |
augtool 'set /files/etc/ssh/sshd_config/PasswordAuthentication yes' && \ | |
augtool 'set /files/etc/ssh/sshd_config/Port 22' && \ | |
cp -a /etc/ssh /etc/ssh.cache && \ | |
ssh-keygen -A && \ | |
rm -rf /var/cache/apk/* && \ | |
#mkdir /var/run/sshd && \ | |
echo 'root:root' | chpasswd | |
# SSH login fix. Otherwise user is kicked off after login | |
# RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | |
#ENV NOTVISIBLE "in users profile" | |
#RUN echo "export VISIBLE=now" >> /etc/profile | |
EXPOSE 22 | |
# ENTRYPOINT ["/usr/sbin/sshd", "-D"] | |
# SSHD END ################################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment