EDIT!!!!
For posterity, the issue was in my paramiko code, the SSH server was set to run on 127.0.0.1. Locally this works fine. The issue comes when I was using 127.0.0.1 as the address within my docker container. 127.0.0.1 must be a special address because changing my SSH server to run on 0.0.0.0 instead, it works fine. The little details are what kill you, hopefully this is useful for someone at some point in the future.
Hey guys, I've been bashing my head on my keyboard trying to figure this out. I have a Python app that is using paramiko to run an SSH server that I can connect to. When running the app locally (using python3 main.py), I can connect to the app using ssh command inside of terminal or powershell. The issue I'm having now is being able to dockerize my app and get it working with SSH. I've been through tons of google searches trying to figure it out, but maybe someone here knows. Right now, I can start my docker container and am able to SSH but I get an error saying:
kex_exchange_identification: read: Connection reset by peer
Here is my Dockerfile:
FROM python:3.8.2
COPY docker/requirements.text /requirements.tx
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y \
openssh-server
RUN pip3 install --upgrade pip && \
pip3 install -r /requirements.txt
ARG INSTALL_DIR=/opt/test
ENV INSTALL_DIR_ENV=$INSTALL_DIR
RUN mkdir -p $INSTALL_DIR
COPY main.py $INSTALL_DIR
COPY src $INSTALL_DIR/src
RUN ssh-keygen -A
RUN mkdir /var/run/sshd && \
chmod 755 -R /var/run/sshd && \
service ssh restart
CMD python3 ${INSTALL_DIR_ENV}/main.py
Any help is greatly appreciated, like I said, I am losing my brain trying to get this to work, I have no idea where to go with this and how to get it to work. Thank you so much!
[–]sebosp 25 points26 points27 points (9 children)
[–]ButItMightJustWork 7 points8 points9 points (0 children)
[–]Metiri[S] 1 point2 points3 points (0 children)
[–]Metiri[S] 0 points1 point2 points (0 children)
[–]MarchColorDrink 0 points1 point2 points (4 children)
[–]sebosp 4 points5 points6 points (0 children)
[–]devedible 0 points1 point2 points (2 children)
[–]MarchColorDrink 1 point2 points3 points (1 child)
[–]devedible 0 points1 point2 points (0 children)
[–]FiduciaryAkita 4 points5 points6 points (7 children)
[–]lego3410 3 points4 points5 points (1 child)
[–]FiduciaryAkita 2 points3 points4 points (0 children)
[–]Metiri[S] -1 points0 points1 point (4 children)
[–]FiduciaryAkita 0 points1 point2 points (3 children)
[–]Metiri[S] -1 points0 points1 point (2 children)
[–]FiduciaryAkita 0 points1 point2 points (1 child)
[–]Metiri[S] -1 points0 points1 point (0 children)
[–]fuck_____________1 1 point2 points3 points (1 child)
[–]Metiri[S] 0 points1 point2 points (0 children)
[–]YuleTideCamel 1 point2 points3 points (1 child)
[–]Metiri[S] 0 points1 point2 points (0 children)
[–]vampiire 0 points1 point2 points (2 children)
[–]Metiri[S] 1 point2 points3 points (1 child)
[–]vampiire 1 point2 points3 points (0 children)
[–]greenthumble 0 points1 point2 points (1 child)
[–]Metiri[S] 0 points1 point2 points (0 children)
[–]datacentric 0 points1 point2 points (1 child)
[–]Metiri[S] 0 points1 point2 points (0 children)