For Centos
Shell脚本:
# vim Dockerfile # mkdir /data01/sshd # vi Dockerfile # sshd # # VERSION 0.0.2 FROM centos:centos7 MAINTAINER yezl RUN yum install -y openssh-server RUN yum install -y openssh-clients RUN yum install -y sed RUN yum install net-tools.x86_64 -y RUN yum install iproute-3.10.0-54.el7.x86_64 -y RUN yum install NetworkManager -y RUN mkdir /var/run/sshd RUN echo 'UseDNS no' >> /etc/ssh/sshd_config RUN sed -i -e '/pam_loginuid.so/d' /etc/pam.d/sshd #set default password RUN echo 'root:123456' | chpasswd RUN /usr/bin/ssh-keygen -A EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"]
For Ubuntu
Shell脚本:
# sshd # # VERSION 0.0.2 FROM ubuntu:14.04 MAINTAINER yezl RUN apt-get update && apt-get install -y openssh-server RUN mkdir /var/run/sshd #set default password RUN echo 'root:123456' | chpasswd RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config # SSH login fix. Otherwise user is kicked off after login RUN sed 's@sessions*requireds*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"]