Skip to content

Instantly share code, notes, and snippets.

Last active Aug 26, 2017
What would you like to do?
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 /root/.ssh/
ONBUILD RUN cat root/.ssh/ >> ~/.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
CMD ["/usr/sbin/sshd", "-D"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment