Docker Centos安装Openssh
环境介绍:
Docker版本:1.5.0
镜像:docker.io:centos latest
操作步骤:
1、启动镜像
docker run -ti centos /bin/bash
2、安装passwd
yum install passwd -y
3、修改Centos root密码
# passwd
Changing password for user root.
New password:
BAD PASSWORD: The password is shorter than characters
Retype new password:
passwd: all authentication tokens updated successfully.
4、安装openssh
yum install openssh-server -y
5、生成公钥、私钥
[root@378ab88a06c8 /]# ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): (直接回车)
Enter same passphrase again: (直接回车)
Your identification has been saved in /etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.
The key fingerprint is:
:3c:::e4::7d::cc::ac:::ab::9e root@378ab88a06c8
The key's randomart image is:
+--[ RSA ]----+
| .o +=+|
| o . . o =o|
| * . o = |
| + o = |
| S o |
| + o . |
| . + |
| E |
| |
+-----------------+
[root@378ab88a06c8 /]# ssh-keygen -t rsa -f /etc/ssh/ssh_host_ecdsa_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): (直接回车)
Enter same passphrase again: (直接回车)
Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key.
Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub.
The key fingerprint is:
:ac:b0:::de:e8:4f:5e::d9:fc:1e:b6:d7: root@378ab88a06c8
The key's randomart image is:
+--[ RSA ]----+
| ... |
| . o * |
| + B = |
| . + o o + |
| . . . S = |
| + + o . . |
| o o . o E|
| . . |
| |
+-----------------+
[root@378ab88a06c8 /]# ssh-keygen -t rsa -f /etc/ssh/ssh_host_ed25519_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): (直接回车)
Enter same passphrase again: (直接回车)
Your identification has been saved in /etc/ssh/ssh_host_ed25519_key.
Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub.
The key fingerprint is:
:0d:b5:fb::a4::::6d::c0::2e:: root@378ab88a06c8
The key's randomart image is:
+--[ RSA ]----+
| E.ooooo=*|
| o.o..++=|
| . . .o+..|
| o . o . |
| S o . |
| . . . . |
| . |
| |
| |
+-----------------+
6、编写启动脚本
# vi /run.sh #!/bin/bash
/usr/sbin/sshd -D # chmod +x /run.sh
7、修改SSH默认端口
# vi /etc/ssh/sshd_config Port
8、退出容器,保存镜像
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
378ab88a06c8 centos:latest "/bin/bash" minutes ago Exited () seconds ago ecstatic_hawking
[root@localhost ~]# docker commit 378ab88a06c8 sshd:centos
9f400c5422109a3403779f4b055c673fae57d1a8809a84bad7a20fcc3574b3dc
8、启动容器
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sshd centos 9f400c542210 minutes ago 271.3 MB
192.168.31.202:/test latest f6c0d93ac266 days ago 315.6 MB
docker.io/centos latest fd44297e2ddb weeks ago 215.7 MB
docker.io/busybox latest 8c2e06607696 weeks ago 2.43 MB
[root@localhost ~]# docker run --net=host -d sshd:centos /run.sh
bbd39bbd7e03ffbd22b88725041793c74c50dbd4316d25bd20c8053265c3f8f1
9、远程连接测试
[root@localhost ~]# ssh 192.168.31.203 -p
The authenticity of host '[192.168.31.203]:222 ([192.168.31.203]:222)' can't be established.
RSA key fingerprint is :2f:::bb::8c::f2:2c:0d::cb:b2::.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.31.203]:222' (RSA) to the list of known hosts.
root@192.168.31.203's password:
Last login: Tue Jun :: from 192.168.7.46
[root@localhost ~]# ll
total
[root@localhost ~]# cd /
[root@localhost /]# ll
total
lrwxrwxrwx root root Apr : bin -> usr/bin
drwxr-xr-x root root Jun : dev
drwxr-xr-x root root Jun : etc
drwxr-xr-x root root Jun home
lrwxrwxrwx root root Apr : lib -> usr/lib
lrwxrwxrwx root root Apr : lib64 -> usr/lib64
drwx------ root root Apr : lost+found
drwxr-xr-x root root Jun media
drwxr-xr-x root root Jun mnt
drwxr-xr-x root root Jun opt
dr-xr-xr-x root root Jun : proc
dr-xr-x--- root root Jun : root
drwxr-xr-x root root Jun : run
-rwxr-xr-x root root Jun : run.sh
lrwxrwxrwx root root Apr : sbin -> usr/sbin
drwxr-xr-x root root Jun srv
dr-xr-xr-x root root May : sys
drwxrwxrwt root root Jun : tmp
drwxr-xr-x root root Apr : usr
drwxr-xr-x root root Apr : var
[root@localhost /]#
Docker Centos安装Openssh的更多相关文章
- Docker Centos安装Redis以及问题处理
之前一篇文章 Redis安装及主从配置 介绍了redis的安装配置,另一篇文件介绍了 Docker Centos安装Openssh .今天将两篇文件结合一下——在Docker Centos环境下搭建r ...
- Docker Centos安装Mysql5.6
之前一篇随笔<Docker Centos安装Openssh> 写的是如何在基础的centos镜像中搭建ssh服务,在此基础上再搭建其他服务.本文继续介绍在centos_ssh基础上搭建my ...
- Docker - CentOS 安装 Docker 和 Docker-Compose
目录 介绍 Docker Docker-Conpose 安装 Docker CE 系统要求 使用 YUM 安装 配置加速器 安装 Docker-Compose 介绍 Docker Docker 是一个 ...
- Docker - CentOS安装Docker
如果要在CentOS下安装Docker容器,必须是CentOS 7 (64-bit).CentOS 6.5 (64-bit) 或更高的版本,并要求 CentOS 系统内核高于 3.10. uname ...
- 1、docker centos 安装
Docker for CentOS: 第一步:使用官方yum仓库 [root@linux-node1 ~]# yum install -y yum-utils [root@linux-node1 ~] ...
- Docker centos 安装syslog
在通常的Linux服务器中,有一些服务本身没有日志,只能通过 tail -f /var/log/messages来查看其运行日志,比如nrpe server.但是,如果想在docker容器中实现这个功 ...
- 4、Docker的安装
docker官方安装文档 Mac上安装Docker Install Docker for Mac | Docker Documentation Windows安装Docker Instal ...
- centos安装docker容器
centos安装docker容器 系统环境需求 docker要运行在centos7系统中,系统为64位机器上,内核最小版本在3.10以上 如果系统为centos6,后面有附带的安装方法 uname - ...
- 在centos,docker中安装HeadlessChrome
在centos6中安装chrome与chrome-driver,中间走了很多弯路,遇到很多坑,现将详细步骤总结如下.参考博客链接:https://blog.csdn.net/u013849486/ar ...
随机推荐
- Qt4过渡至Qt5
技术在不断进步,新知识也理应不断学习!Qt5的发布带给我无尽的好奇心,然而,受项目影响,一直使用VS2008 + Qt4.8也未曾及时更新.这几天,果断装上VS2010 + Qt5.1,开始研究.Qt ...
- Android Service学习之AIDL, Parcelable和远程服务
AIDL的作用 由于每个应用程序都运行在自己的进程空间,并且可以从应用程序UI运行另一个服务进程,而且经常会在不同的进程间传递对象.在Android平台,一个进程通常不能访问另一个进程的内存空 ...
- android 二维码生成
1,activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); set ...
- SQL Server翻译目录
从SQLServerCentral翻译部分Stairways文章,设置目录方便阅读(2015-12更新)SQL Server代理系列第一篇 SQL Server代理概述第二篇 SQL Server代理 ...
- pymongo使用总结
0. 何为pymongo pymongo是操作MongoDB的python模块 1.安装pymongo # easy_install pymongo 2.连接mongodb >>> ...
- javascript中数组的concat()方法 - 数组连接
<html> <head> <title>数组的concat()方法</title> <script> /* 数组的concat()方法: ...
- mysql参数sql_log_bin
如果想在主库上执行一些操作,但不复制到slave库上,可以通过修改参数sql_log_bin来实现. 比如想在主库上修改某个表的定义,但是在slave库上不做修改: master mysql> ...
- Unity3D 通用提示窗口实现分析(Inventory Pro学习总结)
背景 游戏中的UI系统或者叫做GUI窗口系统主要有:主要装备窗口(背包,角色窗口也是一种特殊窗口).确实提示窗口(如购买确认).信息提示窗口(一遍没有按钮,ContexntMenu)和特殊窗口(聊天记 ...
- Linux: .vimrc
set nuset autoindentset cindent"set tabstop=2"set shiftwidth=2set cursorlineset hlsearch&q ...
- monkey测试(转)
一.Monkey测试简介Monkey测试是Android平台自动化测试的一种手段,通过Monkey程序模拟用户触摸屏幕.滑动Trackball.按键等操作来对设备上的程序进行压力测试,检测程序多久的时 ...