日期:2014-05-16  浏览次数:20598 次

linux中启动ssh失败解决方案2009年04月25日
linux中启动ssh失败解决方案2009年04月25日 星期六 下午 06:30在开启SSHD服务时报错.
sshd re-exec requires execution with an absolute path
用绝对路径启动,也报错如下:
Could not load host key: /etc/ssh/ssh_host_key
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Disabling protocol version 1. Could not load host key
Disabling protocol version 2. Could not load host key
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
#/usr/sbin/sshd
在启动sshd服务的时候 出现以下错误提示:
could not load host key : /etc/ssh/ssh_host_dsa_key


查看 /etc/ssh/目录下,缺少这个文件,这个文件是ssh用第二版协议的时候必须要用到的。
解决方法:运行命令手动建立该文件
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key


重新启动sshd服务 /etc/rc.d/sshd start


使用ssh客户端测试连接,通过密码验证。连接正常。


附录:ssh配置文件


1.修改/etc/ssh/sshd_config文件中的以下几行
将#Port 22 前的注释去掉
将#PermitRootLogin no 更改为 #PermitRootLogin yes 这样允许root用户可以远程登录(在线上服务器的时候要屏蔽掉该选项,不能允许root用户直接登录。
将#PasswordAuthentication yes 前的注释去掉
将#PermitEmptyPasswords no 前的注释去掉


保存修改。


将 /etc/inetd.conf中的对应ssh服务前的注释去掉。开机运行该服务。


然后重启sshd服务。/etc/rc.d/sshd start