前天有位客户的 Debian VPS 的 ssh 出现问题,无法正常连接,ssh IP 地址后出现如下错误:
ssh_exchange_identification: Connection closed by remote host
找客户要了 root 密码后登录检查 /etc/ssh/sshd_config 配置文件没有发现问题、防火墙关闭状态、sshd 进程也在,企图重启 sshd 出现如下报错:
# /etc/init.d/ssh restart
Error: Starting OpenBSD Secure Shell server: sshd/var/run/sshd must be owned
by root and not group or world-writable.
原因是 /var/run/sshd/ 运行时环境目录出现权限所属问题,删除这个目录后重启 sshd 就可以了:
# rm -rf /var/run/sshd/ # invoke-rc.d ssh restart