实现条件: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

实现步骤:

[root@node1 ~]# 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:
77:7d:09:dc:9c:d5:dd:41:d3:66:3e:0b:e9:98:dc:32 root@node1.magedu.com
The 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.7(node2)
The authenticity of host '192.168.176.7 (192.168.176.7)' can't be established.
RSA key fingerprint is da:6d::5a::fa::6b:e4:1d:2d::1e:cc::1b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: 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_keys to 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 192.168.176.7(node2)
The authenticity of host 'node2 (192.168.176.7)' can't be established.
RSA key fingerprint is da:6d::5a::fa::6b:e4:1d:2d::1e:cc::1b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2' (RSA) to the list of known hosts.
Last login: Fri Apr :: from node1

以上在用node1去ssh控制node2时就不用输入密码了!直接连接成功!

同样的方法在node2用工具ssh-keygen生密钥对,拷贝公钥至node1,然后在验证ssh node1

基于ssh的多节点之间互信通信的实现的更多相关文章

  1. 基于KepServer实现与S7-1200PLC之间的通信

    对于学习上位机开发,有一种通信方式是必须要了解的,那就是OPC是OLE for Process Control的简称,然而随着技术的不断发展,人们开始对它有了新的定义,比如Open Platform ...

  2. [js高手之路]Vue2.0基于vue-cli+webpack同级组件之间的通信教程

    我们接着上文继续,本文我们讲解兄弟组件的通信,项目结构还是跟上文一样. 在src/assets目录下建立文件EventHandler.js,该文件的作用在于给同级组件之间传递事件 EventHandl ...

  3. Cocos2dx 3.2 节点之间相互通信与设置触摸吞噬的方法

    实际开发中,我们经常会遇到这样的情况.我们有一个层layer1,这个层包含一个menu层,menu1层里又包含了一个节点按钮button1.现在需要实现一个效果:点击button1弹出一个对话框,这个 ...

  4. vc 基于对话框多线程编程实例——线程之间的通信

     vc基于对话框多线程编程实例——线程之间的通信 实例:

  5. vue的父子组建之间的通信(-),基于props和$emit之间的传递

    对于vue而言,以为其核心思想为前端组建化.所以组建之间的通信必不可少. 相信接触过Angularjs的童鞋都知道angularjs的控制器之间的通信机制. 1:父传子:官方的$broadcast() ...

  6. (六)ROS话题---节点之间通信的方式

    1. 理解 ROS 话题: (Ctrl+Alt+T 打开一个新终端) 运行下面的命令: $ roscore (Ctrl+Alt+T 打开一个新终端) $ rosrun turtlesim turtle ...

  7. 基于WSAAsyncSelect模型的两台计算机之间的通信

    任务目标 编写Win32程序模拟实现基于WSAAsyncSelect模型的两台计算机之间的通信,要求编程实现服务器端与客户端之间双向数据传递.客户端向服务器端发送"请输出从1到1000内所有 ...

  8. NS网络仿真,小白起步版,双节点之间的模拟仿真(基于TCP和FTP流)

    set ns [new Simulator] set tracefd [open one.tr w] #开启跟踪文件,记录分组传送的过程 $ns trace-all $tracefd set namt ...

  9. 【Ansible】 基于SSH的远程管理工具

    [Ansible] 参考文档:[http://www.ansible.com.cn/docs/intro.html] 和ansible类似的工具还有saltstack,puppet,sshpass等, ...

随机推荐

  1. c#和java的深拷贝CloneObject

    public static T Clone<T>(this T source) { if (!typeof(T).IsSerializable) { throw new ArgumentE ...

  2. shopNC开发手册

    链接:   https://wenku.baidu.com/view/b9232d24dd3383c4bb4cd2c9.html https://wenku.baidu.com/view/ff1566 ...

  3. Oracle 查询单挑语句运行时间

    pl/sql 不考虑网络IO等影响 declare guidname ):='255fc3db-815a-46c1-9187-ec0256305335'; timespa timestamp:=CUR ...

  4. SQL手工注入学习 一

    sql注入:    (基于DVWA环境的sql注入) 流程:    1.判断是否有SQL注入漏洞    2.判断操作系统.数据库和web应用的类型    3.获取数据库信息看,包括管理员信息(拖库)  ...

  5. linux-lnmp 搭建报错

    一, 大概就是 没有php-nysql拓展 yum -y install php-mysql 二, 编辑php.ini php.ini中 添加extension=mysql.so PHP.ini 中找 ...

  6. unity文件 PlayerPrefs.SetInt 保存 And PlayerPrefs.GetInt读取

    unity文件保存读取PlayerPrefs.SetInt   And  PlayerPrefs.GetInt using UnityEngine; using System.Collections; ...

  7. HDFS基本shell操作

    在客户端输入Hadoop fs,可以查看所有的,hadoop shell # -help [cmd] //显示命令的帮助信息,如: hadoop fs -help ls # -ls(r) <pa ...

  8. 详细讲解Android的网络通信(HttpUrlConnection和HttpClient)

    前言,Android的网络通信的方式有两种:使用Socket或者HTTP,今天这一篇我们详细讲解使用HTTP实现的网络通信,HTTP又包括两种方式编程方式: (1)HttpUrlConnection: ...

  9. ubuntu java开发环境jdk安装

    1. 下载JDK6安装包,我的为32位系统所以选择jdk-6u35-linux-i586.bin 下载地址:http://www.oracle.com/technetwork/java/javase/ ...

  10. FZU 2216——The Longest Straight——————【二分、枚举】

    Problem 2216 The Longest Straight Accept: 17    Submit: 39Time Limit: 1000 mSec    Memory Limit : 32 ...