1.用绝对路径启动,也报错如下:
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
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 (注意使用root用户)
#/usr/local/sbin/sshd
2.ssh和ssl安装过程
ssl安装前,必须先安装zlib库。
安装SSL:
./config --prefix=/usr/local --openssldir=/usr/local/ssl
安装SSH:
./configure --prefix=/usr/local --sysconfdir=/usr/local/ssh --with-ssl-dir=/usr/local/ssl
3.安装SSH,出现Privilege separation user sshd does not exist
在/etc/passwd 中加入: sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin 再次make install 编译安装成功。
4.SSH免密码登录
(1)无选项参数运行SSH
ssh ip 默认情况下,ssh会使用当前用户名作为用户名来连接目标主机。这要求登录机和目标机的用户名一致。
(2)当登录机和目标机使用的用户名不一致时,需要指定用户名。
ssh -l name ip 或 ssh name@ip
5.ssh默认安装在/usr/local/sbin/目录下。