服务器之间,可以互相之间用ssh直接可以登录,不需要输入密码: A服务器地址:192.168.0.1 B服务器地址:192.168.0.2 在A上执行: [root@localhost .ssh]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): 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: 6a:83:7b:6a:52:60:33:de:e0:c1:55:52:2b:c7:59:c9 root@localhost.localdomain [root@localhost .ssh]#cd /root/.ssh [root@localhost .ssh]#cat id_rsa.pub >> authorized_keys 接下来,我们这个文件authorized_keys用scp命令复制到第二台机器的/root/.ssh/目录下 [root@localhost .ssh]#scp authorized_keys 192.168.0.2:/root/.ssh/ 登陆B服务器,此时无需输入密码即可登陆: [root@localhost .ssh]#ssh 192.168.0.2 Last login: Fri Dec 13 17:14:17 2013 如果不奏效的话,检查配置文件/etc/ssh/sshd_config AuthorizedKeysFile .ssh/authorized_keys 并去掉前面的注释,重启sshd服务即可 |
|