docker运行centos使用ssh连接
1、拉取centos7镜像
docker pull centos:centos7

2、运行docker 镜像

3、进入centos容器

4、安装ssh
yum -y install openssh-server

5、启动ssh服务
systemctl start sshd

6、修改 /etc/ssh/sshd_config 配置信息
去掉如下注释
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
permitrootlogin yes
UsePAM yes 改为 UsePAM no
GSSAPICleanupCredentials no改为GSSAPICleanupCredentials yes
去掉UsePrivilegeSeparation sandbox的注释并改为UsePrivilegeSeparation no
7、重启sshd
/usr/sbin/sshd -D

8、设置linux容器的密码
passwd root

9、提交镜像

10、运行新镜像

11、使用ssh连接centos容器
ssh root@宿主机的ip -p 10022
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:175
阅读量:131
阅读量:192
阅读量:74
阅读量:103