1. 获取ubuntu镜像

    1. docker pull ubuntu
  2. 进入容器内部,并且映射端口号23:22代表用23号端口映射容器22端口(ssh通用端口)

    1. docker run -it -p 23:22 ubuntu
  3. 因为ubuntu里面什么都没有,先安装需要的,后面需要什么自己apt-get安装

    1. apt-get update
    2. apt-get install openssh-server
    3. apt-get install vim #为了编辑文件
  4. 配置root密码

    1. passwd
  5. 修改ssh配置 ```bash vim /etc/ssh/sshd_config

添加

PermitRootLogin yes UsePAM no

  1. 6. 开启ssh
  2. ```bash
  3. service ssh start
  1. 连接
    ssh root@localhost:23