2017-11-10 18:31:22 +00:00
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
RUN apk add --no-cache --update \
|
2017-09-28 23:59:15 +00:00
|
|
|
bash \
|
|
|
|
build-base \
|
|
|
|
coreutils \
|
|
|
|
curl \
|
|
|
|
findutils \
|
|
|
|
gcc \
|
|
|
|
libffi-dev \
|
|
|
|
musl-dev \
|
|
|
|
net-tools \
|
|
|
|
openrc \
|
|
|
|
openssh \
|
|
|
|
openssh-server \
|
|
|
|
openssh-sftp-server \
|
|
|
|
openssl-dev \
|
|
|
|
py-boto \
|
|
|
|
py2-pip \
|
|
|
|
python2-dev \
|
|
|
|
rsyslog \
|
|
|
|
sudo \
|
|
|
|
xz \
|
|
|
|
&& pip install --upgrade pip \
|
2017-11-10 18:31:22 +00:00
|
|
|
&& if ! getent passwd <%= @username %>; then \
|
2017-09-28 23:59:15 +00:00
|
|
|
adduser -h /home/<%= @username %> -s /bin/bash -D <%= @username %>; \
|
2017-11-10 18:31:22 +00:00
|
|
|
passwd -d <%= @username %>; \
|
|
|
|
fi \
|
|
|
|
&& echo "<%= @username %> ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
|
|
|
|
&& echo "Defaults !requiretty" >> /etc/sudoers \
|
|
|
|
&& mkdir -p /home/<%= @username %>/.ssh \
|
|
|
|
&& chown -R <%= @username %> /home/<%= @username %>/.ssh \
|
|
|
|
&& chmod 0700 /home/<%= @username %>/.ssh \
|
|
|
|
&& echo '<%= IO.read(@public_key).strip %>' >> /home/<%= @username %>/.ssh/authorized_keys \
|
|
|
|
&& chown <%= @username %> /home/<%= @username %>/.ssh/authorized_keys \
|
|
|
|
&& chmod 0600 /home/<%= @username %>/.ssh/authorized_keys \
|
|
|
|
&& sed -ri 's/^#?PubkeyAuthentication\s+.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config \
|
2017-09-28 23:59:15 +00:00
|
|
|
&& sed -ri 's/^#?PasswordAuthentication\s+.*/PasswordAuthentication no/' /etc/ssh/sshd_config \
|
|
|
|
&& sed -ri 's/^#?ChallengeResponseAuthentication\s+.*/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config \
|
2017-11-10 18:31:22 +00:00
|
|
|
&& sed -ri 's/^#?UsePrivilegeSeparation\s+.*/UsePrivilegeSeparation no/' /etc/ssh/sshd_config \
|
|
|
|
&& echo "UseDNS=no" >> /etc/ssh/sshd_config \
|
2017-09-28 23:59:15 +00:00
|
|
|
&& rc-update add sshd
|
2017-11-10 18:31:22 +00:00
|
|
|
|
|
|
|
EXPOSE 22
|