码迷,mamicode.com
首页 > 系统相关 > 详细

linux双机/多机互信

时间:2015-06-18 20:17:40      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:linux   ssh   互信   免密码   

deven@node1 ~]$ cd

[deven@node1 ~]$ mkdir .ssh (centos6.0无需)

[deven@node1 ~]$ chmod 700 .ssh (centos6.0无需)

[deven@node1 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/deven/.ssh/id_rsa): (回车)

Enter passphrase (empty for no passphrase): (回车)

Enter same passphrase again:(回车)

Your identification has been saved in /home/deven/.ssh/id_rsa.

Your public key has been saved in /home/deven/.ssh/id_rsa.pub.

The key fingerprint is:

89:56:d6:4a:b2:6c:4a:05:86:ae:cd:7d:80:dd:3c:f1 deven@node1

中间过程直接3个回车。在~/.ssh/目录下,生成了两个文件:id_rsa(私钥文件放在本地) 和 id_rsa.pub(公钥文件放在信任服务器)。

在node2上,以用户deven身份进行相同操作。

2. 将所有的公钥文件 id_rsa.pub汇总到一个总的认证文件authorized-keys中:

[deven@node1 ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

[deven@node1 ~]$ ssh deven@node2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

3. 目前node1上存在一份完整的认证key文件,这时候,把它拷到node2主机的对应目录下

[deven@node1 ~]$ scp ~/.ssh/authorized_keys deven@node2:~/.ssh/authorized_keys

用其它的用户也也一样,目标是生成/home/user/.ssh/下的id_rsa, id_rsa.pub,然后将id_rsa.pub追加到集群共享的authorized_keys文件中。

建议将/home/user/.ssh/下所有的文件都设置成700权限。


本文出自 “7727197” 博客,请务必保留此出处http://7737197.blog.51cto.com/7727197/1663099

linux双机/多机互信

标签:linux   ssh   互信   免密码   

原文地址:http://7737197.blog.51cto.com/7727197/1663099

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!