Create an image that provides basic sshd services

Source: Internet
Author: User


  1. Use the dockerfile Method

    Preparations

    # Mkdir sshd_ubuntu create a working directory

    # Cd sshd_ubuntu

    # Touch dockerfile run. Sh the file to be copied to the container after being created

    # Vi run. Sh run. SH Content

    #! /Bin/bash

    /Usr/sbin/sshd-d

    # Cat ~ /. Ssh/id_rsa.pub> authorized_keys copy the public key that needs to be logged on to the container Machine

    Write dockerfile

    ------------------------------------

    # Set the inherited Image

    Fromubuntu: 163

    # Provider Information

    Maintainerfrom buranle, test sshd Images

    # Because the image used has been changed to the APT source of 163, no changes will be made here.

    # Install the SSH service

    Runapt-Get install-y openssh-Server

    Run mkdir-P/var/run/sshd

    Run mkdir-P/root/. SSH

    # Remove PAM module restrictions

    Run sed-Ri's/session required pam_loginuid.so/# session required pam_loginuid.so/G'/etc/PAM. d/sshd

    # Copy the file to the response location and grant the script execution permission

    Addauthorized_keys/root/. Ssh/authorized_keys

    Addrun. sh/run. Sh

    Run chmod755/run. Sh

    # Open Port

    Expose 22

    # Set self-starting commands

    CMD ["/run. Sh"]

    ----------------------------------------------

# Dockerbuild-T sshd: dockerfile.

The success text indicates that our image has been successfully generated.

# Dockerimages

650) This. width = 650; "Title =" 2.png" style = "float: none;" alt = "wkiol1syufty5ryqaadwtmwhg8u389.jpg" src = "http://s3.51cto.com/wyfs02/M01/58/7A/wKioL1SyufTy5RYQAADWtmwHG8U389.jpg"/>

# Dockerrun-D-P 1111:22 sshd: dockerfile

650) This. width = 650; "Title =" 1.png" style = "float: none;" alt = "wkiom1syuszafs3oaagpg2ytazy130.jpg" src = "http://s3.51cto.com/wyfs02/M01/58/7D/wKiom1SyuSzAFs3OAAGPG2ytAzY130.jpg"/>

 

2. Of course we can also use the commit method. We will not introduce it here.

Note: The method of using apt for ease of Source

Change/etc/APT/sources. List or create a new 163. List under source. d. The content is


Deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse

Deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse

Deb http://mirrors.163.com/ubuntu/ trusty-Updates main restricted universe multiverse

Deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse

Deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse

The Deb-Src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse

Deb-Src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse

Deb-Src http://mirrors.163.com/ubuntu/ trusty-Updates main restricted universe multiverse

The Deb-Src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse

The Deb-Src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse


Create an image that provides basic sshd services

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.