Last active
August 26, 2017 15:03
-
-
Save devbkhadka/98792f7bca57f9778793b2db758b3d07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM devkhadka/ubuntuwithssh:1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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