如何使用Dockerfile构建支持SSH等服务的CentOS

今天就跟大家聊聊有关如何使用Dockerfile构建支持SSH等服务的CentOS,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

FROM centos

MAINTAINER Arvin.Cao <arvin@caojiawei.com>

RUN yum install --nogpgcheck -y vim openssh openssh-client openssh-server wget curl

RUN mkdir /var/run/sshd

RUN ssh-keygen -q -b 1024 -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key && \

    ssh-keygen -q -b 1024 -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key && \

    ssh-keygen -q -b 521 -N '' -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key && \

    ssh-keygen -q -b 521 -N '' -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

RUN sed -i \

        -e 's/^#*\(PermitRootLogin\) .*/\1 yes/' \

        -e 's/^#*\(PasswordAuthentication\) .*/\1 yes/' \

        -e 's/^#*\(PermitEmptyPasswords\) .*/\1 yes/' \

        -e 's/^#*\(UsePAM\) .*/\1 no/' \

        /etc/ssh/sshd_config

RUN echo 'root:你的密码' |chpasswd

EXPOSE 22

CMD ["/usr/sbin/sshd","-D"]

看完上述内容,你们对如何使用Dockerfile构建支持SSH等服务的CentOS有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。