Create SSH Docker – Ubuntu latest
Quote from moshe on 24/10/2020, 6:56 amProblem
User wants to create an SSH docker for tests
Solution
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
EXPOSE 22
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
Test
ssh test@localhost -p 2222
Notes
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
Problem
User wants to create an SSH docker for tests
Solution
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
EXPOSE 22
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
Test
ssh test@localhost -p 2222
Notes
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:Quote from moshe on 02/12/2020, 12:01 pmif 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
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