环境:服务器
服务器A(172.16.1.2)dom
服务器B(172.16.1.3)ssh
在服务器Aide
1.执行生成秘钥命令测试
[root@localhost ~]#ssh-keygen -t rsait
Generating public/private rsa key pair. #回车便可io
Enter file in which to save the key (/root/.ssh/id_rsa): ast
Enter passphrase (empty for no passphrase): class
Enter same passphrase again: file
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:
0f:79:e3:71:60:54:d7:1e:77:e7:36:97:9c:21:da:82 root@localhost
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
| ... .. |
| . o o=|
| + o ooO|
| E + . ==|
| S + o .o|
| = + |
| o |
| |
| |
+-----------------+
执行完后会在/root/.ssh/目录下生成两个文件
-rw------- 1 root root 1675 Dec 9 21:42 id_rsa
-rw-r--r-- 1 root root 391 Dec 9 21:42 id_rsa.pub
2.传送秘钥给服务器B
[root@localhost ~]#scp /root/.ssh/id_rsa.pub root@172.16.1.3:/root/.ssh/authorized_keys
root@172.16.1.3's password: #此次须要输入密码
3.测试
[root@localhost .ssh]# ssh root@172.16.1.3
Last login: Tue Dec 9 21:52:54 2014 from 172.16.1.3
[root@Good ~]# #此次不用输入密码了
若是服务器B也须要不用密码ssh到服务器A的话,直接参考以上步骤便可
注:若是服务器A须要与多台ssh信任,直接把其余服务器上生成的秘钥内容复制到服务器A上authorized_keys里便可