./sshd sshd re-exec requires execution with an absolute path
输入全路径执行命令,继续出现错误,如下:
1 2 3 4 5
/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.
执行sshd-keygen命令解决上述问题
1 2 3 4
/usr/sbin/sshd-keygen Generating SSH2 RSA host key: [ OK ] Generating SSH2 ECDSA host key: [ OK ] Generating SSH2 ED25519 host key: [ OK ]
给root生成一个密码
1 2 3 4 5 6
passwd root Changing password for user root. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully.
ssh root@localhost root@localhost's password: Last failed login: Sun Sep 29 09:16:59 UTC 2019 from localhost on ssh:notty There were 3 failed login attempts since the last successful login. Connection to localhost closed.
会遇到连不上去的问题,这时,需要修改/etc/ssh/sshd_config配置。
把里面的UsePAM yes改为UsePAM no
杀掉之前sshd进程后,再次启动
1 2
/usr/sbin/sshd WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several problems.
这时就可以成功登录了。
1 2 3
root@localhost root@localhost's password: Last login: Sun Sep 29 09:20:41 2019 from localhost
生成一个新的镜像
退出容器,并查看容器id
1 2 3
docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ca6a84a514c2 centos "bash" 34 minutes ago Exited (255) 11 seconds ago musing_goodall