Instantly share code, notes, and snippets.

Embed
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 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