ssh_exchange_identification: read: Connection reset by peer
joamla96 opened this issue · comments
When trying to connect to port 22 on my docker system, this error is returend.
This is the Dockerfile i used to build with:
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"]
which i found here: https://docs.docker.com/engine/examples/running_ssh_service/
I have also tried a "smaller and simpler" version:
FROM ubuntu:16.04
RUN mkdir /var/run/sshd
RUN echo root:root | chpasswd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
The command I used to build with:
docker build . -t honeypot
I'm not very well oritentated in either Linux nor Docker. I followed the instructions in repo as much as possible, but I did have some issues installing Docker itself, which i did following a guide elsewhere.
If i follow the example from the docs.docker.com
docker run -d -P --name test_sshd honeypot
docker port test_sshd 22
It works fine, and I can connect.
Running docker ps
I can see the contrainer is created:
b7c1962cfc27 def9be976ec5 "/sbin/init" 38 minutes ago Up 13 minutes 22/tcp honeypot-192.168.122.1
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.