Forum Navigation
You need to log in to create posts and topics.

Create SSH Docker – Ubuntu latest


User wants to create an SSH docker for tests


Create a file called Dockerfile in the directory for the build (or download the docker file ) and copy this contents

FROM ubuntu:latest
RUN apt update && apt install openssh-server sudo -y
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 test
RUN echo ‘test:test’ | chpasswd
RUN service ssh start
RUN mkdir -p /usr/local/tracston
CMD [“/usr/sbin/sshd”,”-D”]

Build the Docker

sudo docker build -t SSHcontainer -f Dockerfile .

Run the Docker

sudo docker run -d -p 2222:22 SSHcontainer


ssh test@localhost -p 2222


the port exposd for the docker during docker run is 2222

Change the default user: test, password: test in the Docker file

Forum changes the backticks and apostrophes which is not compatible to the shell commands. please download dockerfile or change

Uploaded files:

if you get error Exiting 127  add the following ssh commands

RUN sudo apt-get install ssh

RUN sudo systemctl ssh start

RUN sudo systemctl ssh enable

RUN service ssh status