mcas/sshd

By mcas

Updated over 1 year ago

Docker image with Ubuntu and OpenSSH

Image
0

453

SSH Server With Ubuntu Docker Image ...

id => ubuntu/ubuntu

Dockerfile :


FROM ubuntu:latest

# Install base packages
RUN yes | unminimize

# Update packages
RUN apt update && apt upgrade -y

# Install sudo and OpenSSH
RUN apt install sudo openssh-server vim wget git curl net-tools -y

# Create new sudo user
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu
RUN echo "ubuntu ALL=(ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/ubuntu

# Update user password
RUN echo 'ubuntu:ubuntu' | chpasswd

RUN service ssh start

# Expose docker port 22
EXPOSE 22

CMD ["/usr/sbin/sshd","-D"]

Example :

docker run -itd --name sshd mcas/sshd:latest 
docker container inspect -f '{{ .NetworkSettings.IPAddress }}' sshd 
$ ssh ubuntu@IP
ubuntu@IP's password: 
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 4.4.0-210-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
ubuntu@idcontainer~$ 

Docker Pull Command

docker pull mcas/sshd