Ubuntu Installation SSH Service

Source: Internet
Author: User
Tags ssh server docker run

Description: IP 192.168.1.185 ubuntu-docker 14.04

1 , installing Docker

[Email protected]:~$ sudo apt-get install Docker.io installing Docker

[Email protected]:~$ service Docker Status View Docker boot status

[Email protected]:~$ sudo docker version to view the Docker release number

[Email protected]:~$ sudo docker pull bobsha/ping download container: Ubuntu image Address

[Email protected]:~$ sudo docker pull nginx download Nginx image

Docker installs and uses operating systems such as BusyBox, Ubantu, and CentOS.

2 , take Ubuntu image as an example

Ubantu mirrors a lot, using the "-S" parameter, search only those images that have been hidden more than 10 times

[Email protected]:~/apache_ubuntu$ sudo docker search-s ubuntu

[Email protected]:~/apache_ubuntu$ sudo docker pull ubuntu Download official referral source

[email protected]:~$ sudo docker images view image

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Ubuntu latest 08881219DA4A 3 weeks ago 129 MB

bobsha/ping latest f836a9b345e5 months ago 139.5 MB

[Email protected]:~$ sudo docker run-it ubuntu/bin/bash

[Email protected]:/# uname-v View OS version

#40 ~14.04.1-ubuntu SMP Thu Jan 17:43:14 UTC 2015

Installing the Software

[Email protected]:/# apt-get Update Docker official image default compact, updated to download software

[Email protected]:/# apt-get Install Curl Installation Curl

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

3 , creating an image that supports SSH services

a , change the image name

[email protected]:~$ sudo docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Ubuntu latest 08881219DA4A 3 weeks ago 129 MB

[email protected]:~$ sudo docker tag ubuntu ubuntu:14.04

[email protected]:~$ sudo docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Ubuntu latest 08881219DA4A 3 weeks ago 129 MB

Ubuntu 14.04 08881219da4a 3 weeks ago 129 MB

Recommended use of Domestic 163 source address:/etc/apt/sources.list

The default is no netstat, ifconfig, because the image is missing net-tools this package

The default is no VI, VIM, because the image is missing vim this package

b , installing the sshd component

[Email protected]:/# apt-get Install openssh-server installation

[Email protected]:/# mkdir-p/var/run/sshd Create startup directory

[Email protected]:/#/usr/sbin/sshd-d & Startup

Proto refcnt Flags Type State i-node pid/program name Path

[Email protected]:/# NETSTAT-LNP View 22 port

Modify SSH Secure login configuration: Comment out

[Email protected]:/# sed-ri ' s/session required pam_env.so/#session required pam_env.so/g '/etc/pam.d/sshd

Generate secret Key

[Email protected]:/# mkdir root/.ssh create secret key directory

[Email protected]:/# ssh-keygen-t RSA generated key

[Email protected]:/# cat/root/.ssh/id_rsa.pub >/root/.ssh/authorized_keys Copy to Local

Create an SSH server startup script

[Email protected]:/# cat run.sh

#!/bin/bash

/usr/sbin/sshd-d

[Email protected]:/# chmod +x run.sh

Create, use mirroring

[Email protected]:~$ sudo docker commit d00 Sshd:ubuntu created

[sudo] password for sunny:

38696e3ed6fecfb1040932e2a1f0f394d1c2f4e6bff4df0a941853efd7172be4

[Email protected]:~$ sudo docker run-p 10022:22-d sshd:ubuntu/run.sh use

[Email protected]:~$ NETSTAT-LNP View Port

Proto recv-q send-q Local address Foreign address State Pid/program Name

TCP6 0 0::: 10022:::* LISTEN-

C , remote connections need to copy the remote host public key to the container

C.1 You can create a container again

[Email protected]:~$ sudo docker run-p 10023:22-d sshd:ubuntu/run.sh

Fb6b8bd82fda5a39c394708e80393faf5acd4a6dc61b8fddc1a22aeb40d04bb7

[Email protected]:~$ sudo docker exec-it fb6/bin/bash

[Email protected]:/# ssh [email protected]-P 10022

Welcome to Ubuntu 16.04.1 LTS (gnu/linux 3.16.0-30-generic x86_64)

* documentation:https://help.ubuntu.com

* management:https://landscape.canonical.com

* Support:https://ubuntu.com/advantage

Last Login:thu Jan 11:29:27 from 172.17.42.1

[Email protected]:~#

Login successful.

C.2 Remote Host Login

[email protected]. ssh]# ssh [email protected]-P 10022 Remote host Login

Welcome to Ubuntu 16.04.1 LTS (gnu/linux 3.16.0-30-generic x86_64)

* documentation:https://help.ubuntu.com

* management:https://landscape.canonical.com

* Support:https://ubuntu.com/advantage

Last Login:thu Jan 13:42:46 from 192.168.1.176

[Email protected]:~#

Ubuntu Installation SSH Service

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.