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
 

发表评论

邮箱地址不会被公开。 必填项已用*标注

机器人检查 *

分享我的最新文章标题到这里

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据