hello,docker!
FROM centos:centos6 MAINTAINER Feng Honglinrun.shRUN yum -y install openssh-server epel-release && yum -y install pwgen && rm -f /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_rsa_key && ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key && ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key && sed -i "s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config && sed -i "s/UsePAM.*/UsePAM no/g" /etc/ssh/sshd_config ADD set_root_pw.sh /set_root_pw.sh ADD run.sh /run.sh RUN chmod +x /*.sh ENV AUTHORIZED_KEYS **None** EXPOSE 22 CMD ["/run.sh"]
#!/bin/bash if [ "${AUTHORIZED_KEYS}" != "**None**" ]; then echo "=> Found authorized keys" mkdir -p /root/.ssh chmod 700 /root/.ssh touch /root/.ssh/authorized_keys chmod 600 /root/.ssh/authorized_keys IFS=set_root_pw.sh[code]#!/bin/bash if [ -f /.root_pw_set ]; then echo "Root password already set!" exit 0 fi PASS=${ROOT_PASS:-$(pwgen -s 12 1)} _word=$( [ ${ROOT_PASS} ] && echo "preset" || echo "random" ) echo "=> Setting a ${_word} password to the root user" echo "root:$PASS" | chpasswd echo "=> Done!" touch /.root_pw_set echo "========================================================================" echo "You can now connect to this CentOS container via SSH using:" echo "" echo " ssh -p\n'root@ " echo "and enter the root password '$PASS' when prompted" echo "" echo "Please remember to change the above password as soon as possible!" echo "========================================================================"