zoukankan      html  css  js  c++  java
  • ssh 免密及加密远程脚本实现

    windows_host文件路径:C:WindowsSystem32driversetc

    ssh-copy-id -i ~/.ssh/id-rsa.pub root@xxxxxxx 免密验证操作

    /etc/ssh/ssh_config

    执行远程脚本
    #!/bin/bash
    ssh root@xxxxxxxx > /dev/null 2>&1<eeooff
    cd /root
    touch testljc
    exit
    eeooff
    echo done


    yum install openssh-client
    yum install openssh-server


    #PubkeyAuthentication yes

    ##########################################

    yum -y install expect
    expect b.sh
    执行远程登录 密码或者无密码(免密认证)
    #!/usr/bin/expect
    spawn ssh root@10.0.18.65
    expect "*password:" #截取关键词(有密码)
    send "jenkins " #发送密码
    expect "*#" #截取关键词
    send "touch abc.txt "#输入命令
    send "exit " #退出
    interact #保证正确性

    spawn ssh root@10.0.18.22
    send "exit " #输入命令及退出
    interact #保证正确性


    ssh -p 端口 IP 'sh /root/text.sh' 首先是已经免密登录 接着可以执行远程ip的目录下的脚本 且会返回数据 可设置加以互动

  • 相关阅读:
    bzoj1027
    bzoj1069
    poj2079
    poj2187
    bzoj2281
    bzoj2285
    bzoj1558
    bzoj1822
    bzoj1559
    bzoj1570
  • 原文地址:https://www.cnblogs.com/Liang-jc/p/9177257.html
Copyright © 2011-2022 走看看