①构建 sshd 镜像
[root@docker ~]
[root@docker ~]
[root@docker sshd]
FROM centos:7
MAINTAINER xcf-sshd
RUN yum -y update
RUN yum -y install openssh* net-tools lsof telnet passwd
RUN echo "123123" | passwd --stdin root
RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN sed -i '/^session\s\+required\s\+pam_loginuid.so/ s/^/#/' /etc/pam.d/sshd
RUN mkdir -p /root/.ssh && chown root.root /root && chmod 700 /root/.ssh
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]
--
[root@docker sshd]
[root@docker sshd]
[root@docker sshd]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a9d2ea204c6c sshd:new "/usr/sbin/sshd -D" 6 seconds ago Up 5 seconds 0.0.0.0:49153->22/tcp reverent_stonebraker
--
[root@docker sshd]
[root@a9d2ea204c6c ~]