Skip to content

Instantly share code, notes, and snippets.

@devbkhadka
Last active August 26, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devbkhadka/98792f7bca57f9778793b2db758b3d07 to your computer and use it in GitHub Desktop.
Save devbkhadka/98792f7bca57f9778793b2db758b3d07 to your computer and use it in GitHub Desktop.
FROM devkhadka/ubuntuwithssh:1.0
FROM ubuntu:16.04
#install openssh-server
RUN apt-get update && apt-get install -y openssh-server
#This directory needed to run sshd
RUN mkdir /var/run/sshd
#Change sshd config to not allow password authentication
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
#Copy public key to container and add that to authorized_keys
ONBUILD ADD id_rsa.pub /root/.ssh/id_rsa.pub
ONBUILD RUN cat root/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
#Change permissions to meet ssh resitrictions
ONBUILD RUN chmod go-w ~/ && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
#Export ssh port 22 to host machine and start sshd
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