Open sshd Service in Docker

Source: Internet
Author: User
Tags docker ps docker run

    1. SSH Service Installation
      • Installing the SSH Service

        #yum Install Openssh-server-y

      • Install passwd (change password required)

        #yum Install Passwd-y

      • Modifying the Sshd_config configuration file

        Usepam Yes change to Usepam no

      • Turn off host SELinux

        When you use passwd to modify the root password in the container, you will get an error:
        PASSWD:SYSTEM_U:SYSTEM_R:INITRC_T:S0 is isn't authorized to change the password of root
        This time, you need to shut down the host SELinux.

    2. Boot from
      Create the run.sh script under the/root directory and add the following:
       #!/bin/bash service sshd restart while : do sleep 10 done

      In fact, from the start can be used in CMD, but temporarily not ... In the way of unified script execution to prevent exit, feel can regulate the line fine.

    3. Save changes
      • To view the container ID that is running

        #docker PS

      • Commit modified container ID, saved as Centos6.5,tag for sshd

        #docker Commit ID Centos6.5:sshd

    4. Open service

      #docker run-d-P 22:22-t centos6.5:sshd/root/run.sh
      The container is run in a later mode, and the container's port 22 is mapped to port 22 of the host
      In this way, you can connect to the container via SSH from the external network.

Open sshd Service in Docker

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.