docker运行centos使用ssh连接

 时间:2026-02-14 19:07:31

1、拉取centos7镜像

docker pull centos:centos7

docker运行centos使用ssh连接

2、运行docker 镜像

docker运行centos使用ssh连接

3、进入centos容器

docker运行centos使用ssh连接

4、安装ssh

yum -y install openssh-server

docker运行centos使用ssh连接

5、启动ssh服务

systemctl start sshd

docker运行centos使用ssh连接

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

docker运行centos使用ssh连接

8、设置linux容器的密码

passwd root

docker运行centos使用ssh连接

9、提交镜像

docker运行centos使用ssh连接

10、运行新镜像

docker运行centos使用ssh连接

11、使用ssh连接centos容器

ssh root@宿主机的ip -p 10022

  • 如何使用软件对耕升2080炫光OC进行性能测试?
  • win7开机svchost进程占用cpu过高
  • 图解TerraBuilder安装步骤
  • 怎么用A3制作果冻效果的MG动画
  • 360极速版浏览器如何开启挖矿防护功能?
  • 热门搜索
    眩晕症怎么治疗 黑鱼怎么做好吃 女人为什么会来月经 舍利子是怎么形成的 我的世界怎么骑马 猪蹄怎么做好吃 生菜怎么做好吃又简单 重庆酸辣粉的做法 孔子为什么三月不知肉滋味 牙龈肿痛怎么快速消肿