Created
June 5, 2021 14:39
-
-
Save darcwader/f8ada7f8009ea6a91b6f61652e3a82b2 to your computer and use it in GitHub Desktop.
SSH into 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 python:3.8-buster | |
RUN apt-get update && apt-get install -y --no-install-recommends openssh-server | |
RUN mkdir -p /run/sshd && mkdir -p /var/run/sshd && mkdir -p /root/.ssh | |
ARG PWD | |
RUN ssh-keygen -A | |
RUN echo "root:$PWD" | chpasswd | |
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config | |
EXPOSE 22 | |
CMD ["/usr/sbin/sshd", "-D", "-e"] |
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
docker build --build-args PWD=SOMPASS -t ssh . | |
docker run -d --name ssh01 ssh | |
docker inspect -f "{{ .NetworkSettings.IPAddress }}" ssh01 | |
ssh root@IPADDR | |
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -p 22 root@172.17.0.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment