1、拉取镜像:docker pull centos:7

2、运行容器并进入:docker run -i -t -p 1022:22 --name ssh centos:7 /bin/bash

3、安装passwd,openssl,openssh-server:yum install passwd openssl openssh-server -y

4、启动sshd:/usr/sbin/sshd -D &

  这时报以下错误:
  Could not load host key: /etc/ssh/ssh_host_rsa_key
  Could not load host key: /etc/ssh/ssh_host_ecdsa_key
  Could not load host key: /etc/ssh/ssh_host_ed25519_key
 
5、执行以下命令解决:
  # ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' 
  # ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
  # ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''
 
6、修改 /etc/ssh/sshd_config 配置信息
  UsePAM yes 改为 UsePAM no
  UsePrivilegeSeparation sandbox 改为 UsePrivilegeSeparation no
 
7、重启ssh:/usr/sbin/sshd -D &
 
参考:https://www.cnblogs.com/ruanqj/p/7374544.html

相关文章:

  • 2021-12-29
  • 2021-05-27
  • 2021-08-01
  • 2021-07-31
  • 2022-12-23
  • 2021-04-19
  • 2022-12-23
  • 2021-11-08
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-11-27
  • 2021-06-27
  • 2022-02-23
相关资源
相似解决方案