Skip to content

Instantly share code, notes, and snippets.

@nnzv
Last active March 12, 2024 18:02
Show Gist options
  • Save nnzv/5f9a88e7a9f8ad3d9525176e8d765aea to your computer and use it in GitHub Desktop.
Save nnzv/5f9a88e7a9f8ad3d9525176e8d765aea to your computer and use it in GitHub Desktop.
Enable SSH connection in a container.
FROM ubuntu:20.04
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openssh-server \
&& mkdir -p /run/sshd \
&& echo "root:auth" | chpasswd \
&& sed -i 's/^#\(PermitRootLogin\) .*/\1 yes/' /etc/ssh/sshd_config \
&& sed -i 's/^\(UsePAM yes\)/# \1/' /etc/ssh/sshd_config
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment