Created
July 17, 2019 11:45
-
-
Save c18s/3fb96c7e32c58e6bcbc4c68ef9b39aeb to your computer and use it in GitHub Desktop.
SSHD Dockerfile
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 alpine:edge | |
RUN apk add --no-cache openssh sudo | |
RUN ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' | |
RUN adduser -D -s /bin/ash -u 1000 system && \ | |
echo "system ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers && \ | |
sed -i -r 's/^system:!:/system:x:/' /etc/shadow && \ | |
echo "Hello Developers!" > /etc/motd | |
RUN sed -i \ | |
-e 's/^AllowTcpForwarding.*$/AllowTcpForwarding yes/' \ | |
-e 's/^.*#PermitRootLogin.*$/PermitRootLogin no/' \ | |
-e 's/^.*#PermitEmptyPasswords.*$/PermitEmptyPasswords no/' \ | |
-e 's/^.*#TCPKeepAlive.*$/TCPKeepAlive yes/' \ | |
-e 's/^.*#ClientAliveInterval.*$/ClientAliveInterval 300/' \ | |
-e 's/^.*#ClientAliveCountMax.*$/ClientAliveCountMax 0/' \ | |
-e 's/^.*#PasswordAuthentication.*$/PasswordAuthentication no/' \ | |
-e 's/^.*#ChallengeResponseAuthentication.*$/ChallengeResponseAuthentication no/' \ | |
-e 's@^.*AuthorizedKeysFile.*$@AuthorizedKeysFile .ssh/authorized_keys /etc/ssh/authorized_keys@' \ | |
/etc/ssh/sshd_config && \ | |
mkdir -p /run/sshd | |
CMD ["/usr/sbin/sshd", "-D", "-e"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment