“Missing privilege separation directory: /run/sshd“的一个原因记录
问题
使用ssh的过程中出现了一个奇怪的问题。
使用putty远程连接ssh,没有出现问题。
但是使用python的Paramiko的库调用的时候会出现:
Error reading SSH protocol banner[WinError 10054]
而且偶尔还没有报错,这下整不明白了。
使用:
sudo journalctl -f
查看最新的打印日志,每次连接失败都会报错
"Missing privilege separation directory: /run/sshd"
解决
这里网上的方法很多,我这边处理的方法也很简单:
sudo systemctl restart ssh.service
是的,就是重启一下就可以使用了,比网上的其他原因更加离谱。
在重启之前的状态也是inactive (dead) (通过使用sudo systemctl status ssh.service)
应该是启动ssh失败了?
后面我检查是否该ssh.service的开机自启有没有启动,结果是启动的。
但是我手动再次启动确认:
sudo systemctl enable ssh.service
会有这样的警告:
insserv: warning: script 'XXX' missing LSB tags and overrides
猜测是开机自启的过程中出现了问题,导致没有启动成功。
最后在/etc/rc.local添加了一个行:
systemctl restart ssh.service
额外添加了开机自启的保障。