Create a docker image (CentOS, Ubuntu) that supports SSH services via Dockerfile

Source: Internet
Author: User
Tags docker run

Centos:

mkdir Centos-ssh

Vim Centos-ssh/dockerfile

From CentOS

Maintainer blog.rootr.cn [email protected]

RUN Yum install-y openssh-server

RUN mkdir/var/run/sshd

RUN ssh-keygen-q-T rsa-b 2048-f/etc/ssh/ssh_host_rsa_key-n "&& \

Ssh-keygen-q-T ecdsa-f/etc/ssh/ssh_host_ecdsa_key-n "&& \

Ssh-keygen-t dsa-f/etc/ssh/ssh_host_ed25519_key-n "

RUN echo "root:1234" | chpasswd

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

EXPOSE 22

Docker Build-t centos:ssh/root/centos-ssh/

Docker run-d-P 2222:22 centos:ssh

SSH [email protected]-P 2222

Is you sure want to continue connecting (yes/no)? Yes

[email protected] ' s password:1234

[Email protected] ~]#

Ubuntu:

mkdir Ubuntu-ssh

Vim Ubuntu-ssh/dockerfile

From Ubuntu

Maintainer blog.rootr.cn [email protected]

RUN Apt-get update-y

RUN Apt-get install-y Openssh-server

RUN mkdir/var/run/sshd

RUN echo "root:1234" | chpasswd

#允许root用户以任何认证方式登陆 (User password authentication and public key authentication)

RUN sed-i ' s/prohibit-password/yes/g '/etc/ssh/sshd_config

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

EXPOSE 22

Docker Build-t ubuntu:ssh/root/ubuntu-ssh/

Docker run-d-P 2223:22 ubuntu:ssh

SSH [email protected]-P 2223

Is you sure want to continue connecting (yes/no)? Yes

[email protected] ' s password:1234

[Email protected]:~#

Create a docker image (CentOS, Ubuntu) that supports SSH services via Dockerfile

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.