缺省情况下,SSH将使用口令方式进行验证,不需要对系统进行任何配置,就可以使用账号和口令登录到远程服务器。也可以使用基于密钥认证的方式,达到免密码输入登录的效果(下面是具体的配置步骤: 两台服务器IP分别为10.0.1.1和10.0.1.2):
(1)、创建密钥
#ssh-keygen -d //加上参数 d是创建一个基于ssh2的密钥对
#Generating public/private rsa key pair.
#Enter file in which to save the key (/root/.ssh/id_rsa): [回车]
#Created directory ‘/root/.ssh‘.
#Enter passphrase (empty for no passphrase): [回车]
#Enter same passphrase again: [回车]
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
01:90:08:9e:7d:42:69:01:96:52:d7:ca:9f:53:43:df [email protected]
(2)、发布共钥到另一台主机10.0.1.2上
将id_dsa.pub 发布到服务器上,更名为authorized_keys:
#scp /root/.ssh/id_rsa.pub [email protected]:/root/.ssh/authorized_keys
[email protected]‘s password: [输入密码]
(3)、修改权限所有者(192.168.1.2主机上)
# chmod 644 /root/.ssh/authorized_keys