docker centos 开启ssh


运行docker 镜像

docker运行centos使用ssh连接
 
  1. 进入centos容器

    docker运行centos使用ssh连接
  2.  安装ssh

    yum -y install openssh-server

    docker运行centos使用ssh连接
  3. 启动ssh服务

    systemctl start sshd

    docker运行centos使用ssh连接

     

    4.修改 /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

     

    5.重启sshd

    /usr/sbin/sshd -D

     

    6.设置linux容器的密码

    yum install passwd.x86_64

    passwd root

     

    可以ssh连接了,又或者可以提交镜像,再创容器来连接

     

    1. 提交镜像

      docker运行centos使用ssh连接
    2.  

      运行新镜像

      docker运行centos使用ssh连接

     

     

     
     


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM