Docker CentOS How to start the sshd service __docker

Source: Internet
Author: User
Tags docker centos docker run

First, start a pure CentOS container.

Docker run-it--name=sample Centos/bin/bash

Then the SSH localhost will find the following error.

Bash:ssh:command not found

Next I'll teach you how to ssh localhost.

Yum install openssh-server
yum install openssh-clients

Try ssh localhost again and find the error change:
Ssh:connect to host localhost port 22:cannot assign requested address

Indicates that the SSHD service is not yet open. This can also be verified with PS-EF.

Because it is docker inside CentOS, so service and systemctl are not good to use.

Try to run/usr/sbin/sshd manually

reported the following error:

Could not load host key:/etc/ssh/ssh_host_rsa_key
could not load host key:/etc/ssh/ssh_host_ecdsa_key
could not Load host key:/etc/ssh/ssh_host_ed25519_key
sshd:no Hostkeys available--exiting.

Manual execution of/usr/sbin/sshd-keygen-a

Re-execution/usr/sbin/sshd successful.

To bypass this machine, perform the following command:

Ssh-keygen-t Rsa-p '-F ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 0600 ~/.ssh/
Authorized_keys

At this point, performing an ssh localhost can be successful.

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.