【问题标题】:ssh_exchange_identification: read: Connection reset by peer; ubuntu in Dockerssh_exchange_identification:读取:对等方重置连接; Docker 中的 ubuntu
【发布时间】:2018-11-01 03:03:05
【问题描述】:

我正在尝试在 Docker 中设置一些 Ubuntu 映像,以用作蜜罐。

我遵循了这里的指南: https://github.com/mrschyte/dockerpot

这是我使用的 Docker 文件的副本:

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"]

运行docker ps可以看到contrainers已经创建好了:

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

但是当我尝试从我的机​​器连接到它们时,连接被重置并出现错误:ssh_exchange_identification: read: Connection reset by peer

【问题讨论】:

    标签: linux ubuntu docker ssh openssh


    【解决方案1】:

    从初始化脚本中删除/sbin/init,解决了这个问题。

    不应在 docker 中使用有关此内容的内容,因为它可能不会初始化服务。

    【讨论】:

    • 我认为这行 CMD ["/usr/sbin/sshd", "-D"] 在 Dockerfile 上不需要,对吧?
    • 它可以正常工作,但不确定是否需要。不想重建图像,现在它似乎正在工作。
    • 如何从初始化脚本中删除 /sbin/init?
    • 脚本来自github.com/mrschyte/dockerpot项目,在scripts下。根据指南,它位于/usr/bin/honeypot。该脚本在第 17 行运行 docker 容器,它的最后一部分包含 sbin/init
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-15
    • 2019-02-14
    • 1970-01-01
    相关资源
    最近更新 更多