1.expect方法

#!/bin/bash

checkTrust()
{
expect -c '
set timeout 2;
spawn ssh $1 "expr 12345678 + 87654321"
expect {
"*yes/no*" {send \003;}
"*assword*" {send \003;}
-re "#|$|>" {send exit\r;}
}
expect eof;'
} result=`checkTrust $1 | grep "99999999"` echo result=$result
#./checkTrust.sh 192.168.0.10
result=99999999 #./checkTrust.sh 11.11.11.11
result=

2.ssh 返回值

ssh 192.168.0.100 -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no "echo a" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Trust not exist."
fi

验证两台机器已经建立的ssh互信的更多相关文章

  1. 两台linux之间建立信任关系,实现免密码ssh远程登录或scp数据上传

    两台linux之间建立信任关系,实现免密码远程登录或数据上传 1.执行ssh-keygen命令,生成建立安全信任关系的证书: linux1上:执行命令  ssh-keygen  -t rsa 在程序提 ...

  2. linu SSH 不在同一网段的两台机器如何通过ssh通信,SSH限制特定网段登陆的方法

    1. linu SSH 不在同一网段的两台机器如何通过ssh通信 https://blog.csdn.net/lhf19891003/article/details/39895763 https:// ...

  3. keepalived两台机器同时出现vip问题

    配置文件: 主:192.168.1.14 ! Configuration File for keepalived global_defs { script_user root enable_scrip ...

  4. Linux下 两台机器文件/文件夹 相互拷贝

    Linux下 两台机器文件/文件夹 相互拷贝 设有两台机器 :A:*.101及 B:*.102. 把A下的.temp/var/a.txt拷贝到B机器的/text/目录下: 进入B机器:scp root ...

  5. [synergy]两台机器公用键盘鼠标

    两台机器公用键盘鼠标 如果是Linux: 下载synergy相关的deb包,然后

  6. ROS知识(11)----同步两台机器时钟

    两台机器同时运行过程中,对于ROS的tf变换,其要求两台机器的时钟要保持一致. 1.查询时间 首先通过以下命令,看两台机器时钟是否有差异.在本机上,查看远程master的机器时间: ntpdate - ...

  7. 三台机器之间root用户ssh互信配置

    三台机器之间root用户ssh互信配置 (1)在所有的主机上执行:ssh-keygen -t rsa # 在每台都需要操作,一路回车 (2)将所有机子上公钥(id_rsa.pub)导到一个主机的/ro ...

  8. ssh两台机器建立信任关系无密码登陆

    在建立信任关系之前先看看基于公钥.私钥的加密和认证. 私钥签名过程 消息-->[私钥]-->签名-->[公钥]-->认证 私钥数字签名,公钥验证 Alice生成公钥和私钥,并将 ...

  9. centos 7 两台机器搭建三主三从 redis 集群

    参考自:https://linux.cn/article-6719-1.htmlhttp://blog.csdn.net/xu470438000/article/details/42971091 ## ...

随机推荐

  1. Ubuntu 16.04防火墙

    防火墙(ufw) 说明:简单版本的防火墙,底层依赖于iptables. 安装:sudo apt-get install ufw 查看状态:sudo ufw status 开启/关闭:sudo ufw ...

  2. nRF51822EK_PRO

    ARMCC5LIB = C:\Keil\ARM\ARMCC\lib dd if=/dev/zero of=tmp.500M bs=500M count=1 Developer Home

  3. [转] Linux History(历史)命令用法 15 例

    [From]https://linuxtoy.org/archives/history-command-usage-examples.html 如果你经常使用 Linux 命令行,那么使用 histo ...

  4. Q221 最大正方形

    在一个由 0 和 1 组成的二维矩阵内,找到只包含 1 的最大正方形,并返回其面积. 示例: 输入: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 输出: 4 cla ...

  5. po'j2559 Largest Rectangle in a Histogram 单调栈(递增)

    Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 29498 ...

  6. C#面试:委托

    面试常见题: 1.委托是什么?★☆ 2.为什么需要委托?★☆ 3.委托能用来做什么?★☆ 4.如何自定义委托★☆ 5..NET默认的委托类型有哪几种?★☆ 6.怎样使用委托?★★★ 7.多播委托是什么 ...

  7. rabbitmq无用使用guest用户远程连接

    最近开始使用rabbitmq,因为不了解,浪费了不少时间,记录如下: 使用场景:服务器(linux)上部署了一个app1模块,该模块向rabbitmq发送消息,我想让这个模块的消息发送到我本地(win ...

  8. Linux安装phpMywind

    1.安装MySQL http://www.cnblogs.com/wangshuyi/p/6091244.html 2.安装apache.php.及其扩展 yum install -y httpd p ...

  9. maevn HelloWorld 基本命令

    总结: Mvn clean compile:编译主代码 Mvn clean test:执行测试代码 Mvn clean package:打包 Mvn clean install: 安装到本地仓库 执行 ...

  10. [问题解决]Android7.0上PopupWindow的showAsDropDown位置问题

    [问题解决]Android7.0上PopupWindow的showAsDropDown位置问题 /** * Created by diql on 2017/02/16. */ 问题说明 我的popup ...