zoukankan      html  css  js  c++  java
  • ssh登录docker容器

    1、启动一个docker容器
    # docker run -t -i ubuntu/ruby:v1 /bin/bash
    2、然后在容器里,安装openssh-server openssh-client
    # apt-get install openssh-server openssh-client
    3、完成之后,修改root密码
    # passwd
    4、退出容器,并保存以上修改
    # docker commit 3ea7a99a0025 ubuntu/ruby:v2
    5、停止,并删除刚才的容器
    # docker stop [container-id]  
    # docker rm [container-id]
    查看容器id
    # docker ps -a
    查看镜像列表
    # docker images
    6、用刚保存的镜像,后台启动一个新的容器
     docker run --name [image-name] -i -t -p 50001:22 [image-id]
    例: # docker run -d -p 50001:22 ubuntu/ruby:v2 /usr/sbin/sshd -D
    7、ssh远程登录该容器
    # ssh root@localhost -p 50001

    如果想要通过ssh密钥登录,则在第2步,修改 /etc/ssh/sshd_config 文件,将RSAAuthentication 和 PubkeyAuthentication 后面的值都改成yes ,保存。
    将本地.ssh下的id_rsa.pub上传到容器中的 id_rsa.pub,并 # mv /root/.ssh/id_rsa.pub/root/.ssh/authorized_keys,然后 # chmod 600 /root/.ssh/authorized_keys 即可.

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

    http://blog.csdn.net/qq626387/article/details/50506636

    http://www.linuxidc.com/Linux/2013-07/87368.htm

  • 相关阅读:
    hadoop mysql install (5)
    hadoop redis install (4)
    hadoop mongodb install(3)
    hadoop hbase install (2)
    水平交错效果显示图像
    实现推拉效果显示图片
    百叶窗效果显示图像
    以椭圆形显示图像
    图像的放大与缩小
    鼠标拖拽图像
  • 原文地址:https://www.cnblogs.com/syqlp/p/6567537.html
Copyright © 2011-2022 走看看