Skip to content

Instantly share code, notes, and snippets.

@duzun
Created August 29, 2017 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duzun/9c3702ae874cb7193f9062a20ccfd74f to your computer and use it in GitHub Desktop.
Save duzun/9c3702ae874cb7193f9062a20ccfd74f to your computer and use it in GitHub Desktop.
SSHD for Alpine container
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