I'm trying to setup some Ubuntu images in Docker, to be used as honeypots.
I've followed a guide from here: https://github.com/mrschyte/dockerpot
This is a copy of the Docker file i use:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# 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
CMD ["/usr/sbin/sshd", "-D"]
Running docker ps
I can see that the contrainers are created:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b7c1962cfc27 def9be976ec5 "/sbin/init" 45 minutes ago Up 19 minutes 22/tcp honeypot-192.168.122.1
but when I try to connect to them from my machine, the connection is reset with the error: ssh_exchange_identification: read: Connection reset by peer
Removing /sbin/init
from the init script, fixed the issue.
Something about this should not be used in docker as it may not initialize the services.