docker配置ssh连接


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


免责声明!

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



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