-
-
Save hortinstein/5d92bf54773575f5edf8e5070d80170c to your computer and use it in GitHub Desktop.
ssh docker
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 build:latest | |
MAINTAINER Alex Hortin | |
EXPOSE 22 | |
EXPOSE 80 | |
############################## | |
# installing tiny init (tini) | |
############################## | |
RUN apk add --update tini gcc make | |
############################## | |
#configuring ssh | |
############################## | |
# add openssh and clean | |
RUN apk add --update openssh \ | |
&& rm -rf /tmp/* /var/cache/apk/* | |
# add entrypoint and startup script | |
ADD docker-entrypoint.sh /usr/local/bin | |
ADD startup.sh /usr/local/bin | |
#make sure we get fresh keys | |
RUN rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key | |
#setup the ssh server | |
RUN mkdir /root/.ssh | |
RUN chmod 0700 /root/.ssh | |
COPY ./ssh/id_rsa.pub /root/.ssh/authorized_keys | |
RUN chmod 0600 /root/.ssh/authorized_keys | |
############################## | |
# installing vulnerable web server | |
############################## | |
COPY executables/central_logging_server /root/server | |
ENTRYPOINT ["docker-entrypoint.sh"] | |
CMD ["startup.sh"] | |
-------------------------------------------startup.sh | |
#!/bin/sh | |
python2.7 root/server & | |
/usr/sbin/sshd -D | |
------------------------------------------- | |
#!/bin/sh | |
if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then | |
# generate fresh rsa key | |
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa | |
fi | |
if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then | |
# generate fresh dsa key | |
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa | |
fi | |
#prepare run dir | |
if [ ! -d "/var/run/sshd" ]; then | |
mkdir -p /var/run/sshd | |
fi | |
/sbin/tini -- | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment