Skip to content

Instantly share code, notes, and snippets.

@tonywangcn
Created March 19, 2017 05:40
Show Gist options
  • Save tonywangcn/313080736f2f3674140788666a001cb3 to your computer and use it in GitHub Desktop.
Save tonywangcn/313080736f2f3674140788666a001cb3 to your computer and use it in GitHub Desktop.
ubuntu dockerfile with ssh
FROM ubuntu:16.04
MAINTAINER TonyWang <[email protected]>
RUN apt-get update && apt-get install -y sudo && apt-get install -y software-properties-common python-software-properties && apt-get install net-tools && apt-get install -y iputils-ping && apt-get install -y vim && apt-get install -y tcptrack
RUN apt-get update && sudo add-apt-repository "deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse"
RUN sudo add-apt-repository "deb http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse"
RUN sudo add-apt-repository "deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse"
RUN sudo add-apt-repository "deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse"
RUN sudo add-apt-repository "deb http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse"
RUN sudo add-apt-repository "deb http://archive.canonical.com/ubuntu/ xenial partner"
RUN sudo add-apt-repository "deb http://extras.ubuntu.com/ubuntu/ xenial main"
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:test123' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
#RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
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