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 ...
随机推荐
- ■ apache隐藏、混淆php后缀名的几种方法
经常看见有些网站www.***.com/kkk或者www.***.com/kkk.jsp这样访问,其实kkk可能是个php脚本文件,被隐藏了或者混淆了.php后缀,这样至少不会让别人一眼看出网站是ph ...
- Java遇见HTML——JSP篇之JSP内置对象(上)
一.JSP内置对象简介 1.1.内置对象简介 JSP内置对象是WEB容器中创建的一组对象,可以直接使用不需要new,如截图中的out 对象. JSP有九大内置对象: 五大常用对象: out.reque ...
- 内存映射文件mmap
1. mmap mmap可以把磁盘文件的一部分直接映射到内存,这样文件中的位置直接就有对应的内存地址,对文件的读写可以直接用指针而不需要read/write函数.使用内存映像文件的另一个优点是可以共 ...
- ftp主动模式 被动模式 和iptables 设置
FTP协议有两种工作方式:PORT方式和PASV方式,中文意思为主动式和被动式. Port模式:ftp server:tcp 21 <------client:dynamic ftp se ...
- Jenkins自动构建
Jenkins is an award-winning, cross-platform, continuous integration and continuous delivery applicat ...
- 前端bower使用
Bower是一个客户端技术的软件包管理器,是由twitter推出的.它可用于搜索.安装和卸载如JavaScript.HTML.CSS之类的网络资源.其他一些建立在Bower基础之上的开发工具,如Yeo ...
- PostgreSQL Monitor pg_activity
PostgreSQL Monitor pg_activity Command line tool for PostgreSQL server activity monitoring. https:// ...
- 转:Python itertools模块
itertools Python的内建模块itertools提供了非常有用的用于操作迭代对象的函数. 首先,我们看看itertools提供的几个"无限"迭代器: >>& ...
- Winform ListView 元素拖动
//ListView 属性 /* AllowDrop : True */ ListView objLVDrag; private void listView_DragDrop(object sende ...
- .NET: 配置文件
VS里项目->添加新项->应用程序配置文件 <?xml version="1.0" encoding="utf-8" ?> <co ...