月度归档:2013年03月

Redhat Linux之间互相SSH访问无密码设置

   这里讲的无密码,不是说用户不设置密码,而是对于信任的客户端登录主机,不用输入密码而已。
   假设有两台Linux主机AS-1和AS-2。那么在两台机器上分别执行如下的命令:

[wanghp@AS-1 ~]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wanghp/.ssh/id_rsa):                                  
Created directory '/home/wanghp/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/wanghp/.ssh/id_rsa.
Your public key has been saved in /home/wanghp/.ssh/id_rsa.pub.
The key fingerprint is:
6f:00:a3:0f:1a:9f:d7:b8:1e:0c:0f:ac:51:b9:02:c0 wanghp@poc4dev
The key's randomart image is:
+–[ RSA 2048]—-+
|o                |
|.E   .           |
|.   o o          |
| . o o o         |
|  + B   S        |
|   B O o o       |
|  o o B . o      |
|     . o .       |
|     .o          |
+—————–+
[wanghp@AS-1 ~]$ cp /home/wanghp/.ssh/id_rsa.pub /home/wanghp/.ssh/authorized_keys

然后将AS-1中id_rsa.pub的内容拷贝到AS-2中的authorized_keys文件中,将AS-2中id_rsa.pub的内容拷贝到AS-1中的authorized_keys文件中。

如果不行的话,可以检查一下:/etc/ssh/sshd_config文件中的如下配置,将#去掉,重启sshd服务。

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys