移植ubuntu rootfs过程中出现ssh问题

root@kal:~# service ssh start
Job for ssh.service failed because the control process exited with error code.
See "systemctl status ssh.service" and "journalctl -xe" for details.

查看原因

root@kal:~# /usr/sbin/sshd -T
sshd: no hostkeys available -- exiting.

 

解决过程:
#ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
#ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

如下ok

root@kal:~# ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
Generating public/private rsa key pair.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /etc/ssh/ssh_host_rsa_key
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub
The key fingerprint is:
SHA256:2PQheuQ/LwNqPwz2K25AsF9xyt0ZnnJWhu7ATB38n3M root@huida
The key's randomart image is:
+---[RSA 3072]----+
| o.o |
| . . o = o |
| o . O++.B |
| . . +B*oO.. |
| o .o S*. . . |
| o o.... + E|
| o = .o o |
| = + oo |
| +.ooo o. |
+----[SHA256]-----+
root@kal:~# /usr/sbin/sshd -T
Missing privilege separation directory: /run/sshd
root@kal:~# service ssh start
root@kal:~#