博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
基于ssh的多节点之间互信通信的实现
阅读量:6370 次
发布时间:2019-06-23

本文共 2118 字,大约阅读时间需要 7 分钟。

实现背景:在集群集群服务中的节点管理,必须站在一个正常的节点上,去远程管理:启动和关闭某个节点的服务(第一个节点肯定自己启动的除外),所以集群中各节点之间必须建立ssh互信通信方式机制。 基于密钥认证方式无密码的ssh互信通信。

实现条件:node1:192.168.176.6 主机名称是node1.magedu.com;

                    node2:192.168.176.6 主机名称是node1.magedu.com;

实现目的:在节点node1上可以ssh 192.168.176.7    ssh node2  ;在节点node2上可以ssh 192.168.176.6    ssh node1

实现步骤:

(1)在node1 上使用ssh-keygen 工具生成公钥和私钥

[root@node1 ~]# ssh-keygen -t rsaGenerating 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:77:7d:09:dc:9c:d5:dd:41:d3:66:3e:0b:e9:98:dc:32 root@node1.magedu.comThe key's randomart image is:+--[ RSA 2048]----+|              .+B||            . o @||             o.B ||             +..o||        S o * o.+||         . E o o ||            o    ||                 ||                 |+-----------------+

(2)在node1上使用ssh-copy-id工具将/root/.ssh/id_rsa.pub.远程拷贝至node的~/.ssh/目录下

[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.176.7The authenticity of host '192.168.176.7 (192.168.176.7)' can't be established.RSA key fingerprint is da:6d:09:5a:86:fa:17:6b:e4:1d:2d:57:1e:cc:32:1b.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.176.7' (RSA) to the list of known hosts.root@192.168.176.7's password:Now try logging into the machine, with "ssh 'root@192.168.176.7'", and check in:  .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.

(3)在node1验证ssh 192.168.176.7 ,然后在验证ssh node2

[root@node1 heartbeat]# ssh node2The authenticity of host 'node2 (192.168.176.7)' can't be established.RSA key fingerprint is da:6d:09:5a:86:fa:17:6b:e4:1d:2d:57:1e:cc:32:1b.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'node2' (RSA) to the list of known hosts.Last login: Fri Apr 22 10:29:40 2016 from node1
同样的方法在node2用工具ssh-keygen生密钥对,拷贝公钥至node1,然后在验证ssh node1
 

转载于:https://www.cnblogs.com/the-study-of-linux/p/5428538.html

你可能感兴趣的文章
canto配置(1)——添加feeds
查看>>
JavaScript强化教程——jQuery AJAX 实例
查看>>
linux下配置tomcat
查看>>
HTML5 canvas实现一个简易画板
查看>>
ThinkPHP5无限循环输出无限分类【方案三】
查看>>
实易科技2012年智能DNS领域取得多项突破性进展
查看>>
Discuz安装时候出现乱码 -- 问题解决方法
查看>>
Maven——学习(1):基础概念
查看>>
Java中HashMap,LinkedHashMap,TreeMap的区别
查看>>
iPhone消息推送机制实现与探讨(转)
查看>>
iphone 线程 NSCondition NSThread
查看>>
Debian8添加kali源并安装metasploit
查看>>
Linux redhat 5.7 安装 Teamviewer7
查看>>
android EditText inputType说明
查看>>
在mac os中用http_load,valgrind和xdebug来分析php程序
查看>>
centos 安装Audacious 播放器
查看>>
交叉熵代价函数(作用及公式推导)
查看>>
如何配置PostgreSQL允许被远程访问
查看>>
Spring中property-placeholder的使用与解析
查看>>
触发器学习之入门(增、删、改、增删改)
查看>>