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