博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker中Ubuntu镜像添加openssh-server服务
阅读量:6949 次
发布时间:2019-06-27

本文共 1576 字,大约阅读时间需要 5 分钟。

hot3.png

Docker中Ubuntu镜像添加openssh-server服务 博客分类: docker

Docker中Ubuntu镜像添加openssh-server服务,有需要的朋友可以参考下。

1,首先,需要从docker官网获得centos或Ubuntu镜像

2,当本地已有Ubuntu镜像后(大概200M左右大小),使用如下命令

docker run -t -i ubuntu /bin/bash

即可启动一个容器,并放入Ubuntu镜像

 

 

3,更新源, apt-get update

 

接着就可以使用 apt-get install openssh-client openssh-server 来安装openssh服务了

 

需要把此镜像保存一下:

 

 

docker commit [container-id] [image-id]

在把刚刚的container干掉:

 

 

 

docker stop [container-id]

嗯,还需要将这个container删除掉

 

 

 

docker rm [container-id]

最后,加载刚刚保存到的最新的image,放入到新的容器中去:

 

 

 

docker run --name [image-name] -i -t -p 50001:22 [image-id]

 

4,启动openssh服务

 

 

/etc/init.d/ssh start

5,此时可以从其他机器登陆到这个docker容器里了

 

6,可能出现一些错误使得一登陆进去就直接关闭连接了:

 

 

[root@Wshare84 start_docker_sh]# ssh root@10.10.2.84 -p 50001The authenticity of host '[10.10.2.84]:50001 ([10.10.2.84]:50001)' can't be established.RSA key fingerprint is aa:05:84:4c:f2:15:f3:04:89:9c:04:33:0d:15:14:1f.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '[10.10.2.84]:50001' (RSA) to the list of known hosts.root@10.10.2.84's password: Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 2.6.32-431.el6.x86_64 x86_64) * Documentation:   Last login: Wed Jan 21 01:25:17 2015 from 172.17.42.1Connection to 10.10.2.84 closed.

此时解决方案:

 

 

 

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_keyssh-keygen -t rsa -f  /etc/ssh/ssh_host_rsa_key

echo 'root:yourpasswd' | chpasswd //设置root密码

vi  /etc/ssh/sshd_config

将PermitRootLogin 改为 yes,将UsePAM 改为 no。

 

 

重启服务:

 

 

/etc/init.d/ssh restart

http://www.aichengxu.com/view/42584

 

 

http://blog.sina.com.cn/s/blog_600e56a60102vwjc.html

转载于:https://my.oschina.net/xiaominmin/blog/1598871

你可能感兴趣的文章
jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中
查看>>
MATLAB 2012b license checkout failed
查看>>
妙趣横生的算法:亲密数
查看>>
springboot项目创建,及运行
查看>>
from gff3 get gene fasta sequence(2)
查看>>
zabbix系列(二)zabbix3.0.4添加对mysql数据库性能的监控
查看>>
【文文殿下】 [USACO08MAR]土地征用 题解
查看>>
HashMap、TreeMap、LinkedHashMap、hashtable的区别 小记
查看>>
股票基础常识
查看>>
c++ 编译时函数匹配和运行时类型识别
查看>>
Mybatis-generator生成Service和Controller
查看>>
系统架构设计师-软件水平考试(高级)-理论-数据库
查看>>
前端面试经典题目合集(HTML+CSS)一
查看>>
计算最大子段(分治法)
查看>>
Ubuntu安装PyCharm
查看>>
利用python实现词向量训练----
查看>>
eclipse中如何去掉复制代码有行号的数字
查看>>
冒泡排序
查看>>
转:ActiveMQ的作用总结(应用场景及优势)
查看>>
2-范数、1-范数、···
查看>>