docker启动sshd报错Could not load host key: /etc/ssh/ssh_host_rsa_key和Permissions 0640 for ‘/etc/ssh/ssh_
启动sshd报错第一个错误,docker容器启动sshd没有文件[root@3ca6bba2a824 yum.repos.d]# /usr/sbin/sshdCould not load host key: /etc/ssh/ssh_host_rsa_keyCould not load host key: /etc/ssh/ssh_host_ecdsa_keyCould not load host
·
启动sshd报错
第一个错误,docker容器启动sshd没有文件
[root@3ca6bba2a824 yum.repos.d]# /usr/sbin/sshd
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
sshd: no hostkeys available -- exiting.
只需要从宿主机把这个三个文件cp到容器内就可以解决
[root@zheng ssh]# docker cp /etc/ssh/ssh_host_rsa_key 3ca6bba2a824:/etc/ssh/
[root@zheng ssh]# docker cp /etc/ssh/ssh_host_ecdsa_key 3ca6bba2a824:/etc/ssh/
[root@zheng ssh]# docker cp /etc/ssh/ssh_host_ed25519_key 3ca6bba2a824:/etc/ssh/
再从容器启动sshd还是报错
第二个错误,文件权限错误,复制过来的权限太高了
[root@3ca6bba2a824 ansible]# /usr/sbin/sshd
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
key_load_private: bad permissions
Could not load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
key_load_private: bad permissions
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
key_load_private: bad permissions
Could not load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.
修改一下这三个文件的权限,改成600
然后查询一下进程和端口确认
[root@3ca6bba2a824 ssh]# chmod 600 ssh_host_ecdsa_key
[root@3ca6bba2a824 ssh]# chmod 600 ssh_host_ed25519_key
[root@3ca6bba2a824 ssh]# chmod 600 ssh_host_rsa_key
[root@3ca6bba2a824 ssh]# /usr/sbin/sshd
[root@3ca6bba2a824 ssh]# ps -ef |grep sshd
root 212 0 0 07:49 ? 00:00:00 /usr/sbin/sshd
root 214 193 0 07:50 pts/3 00:00:00 grep --color=auto sshd
看到了22端口
[root@3ca6bba2a824 ssh]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 212/sshd
tcp6 0 0 :::22 :::* LISTEN 212/sshd
解决成功
更多推荐
已为社区贡献2条内容
所有评论(0)