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 ...
随机推荐
- OC类方法和实例方法中的self区别
OC类方法和实例方法中的self Objective-C里面既有实例方法也类方法.类方法(Class Method) 有时被称为工厂方法(Factory Method)或者方便方法(Convenien ...
- js转换 /Date(1464671903000)/ 格式的日期的方法
转换成:2016-07-11 function getFDate(date) { var d = eval('new ' + date.substr(1, date.length - 2)); var ...
- WebDriver中启动不同的浏览器
import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; im ...
- Hint
select /*+ first_rows(20) */ * from t where id<20 --分页 select /*+ all_rows */ * from ...
- java.net.BindException: Address already in use: JVM_Bind
是端口占用,如果修改端口后仍提示这样的错误,可能是eclipse自动关闭或正在运行服务非正常中断导致端口没有关闭,这时你再启动,还是提示java.net.BindException: Address ...
- PG sys function
The System Catalogs of PostgreSQLscott=# \dS List of relations Schema | Name | Type | Owner -------- ...
- angular 和jq 的AJAX的请求区别
最近项目中使用angular,结果发现后台没法获取参数,所以,稍微研究了一下两者在发送ajax时的区别. 注意angular和jquery的ajax请求是不同的. 在jquery中,官方文档解释con ...
- [原创]java WEB学习笔记76:Hibernate学习之路---Hibernate介绍,hibernate 环境的搭建
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- [原创]java WEB学习笔记45:自定义HttpFilter类,理解多个Filter 代码的执行顺序,Filterdemo:禁用浏览器缓存的Filter,字符编码的Filter,检查用户是否登陆过的Filter
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- NovaMind使用教程
NovaMind 使用教程 目前NovaMind在网络上基本没什么中文资料,它自带的"欢迎"导图也只有英文版本.导致很多朋友对这个工具的使用技巧不够了解.今天我把自己的使用心得整理 ...