zoukankan      html  css  js  c++  java
  • ssh 互通脚本

    实现了 主机到指定机器的ssh免密码登录。 若要实现互通, 则在机器列表的每台机器上执行该脚本。

    192.168.1.22 root test
    192.168.1.25 root test
    192.168.1.26 root test
    

    info.list 如上结构。

    脚本使用expect命令,需要安装expect包,centos下使用 yum instal expect

    #!/usr/bin/expect
    set info [open "info.list" r]
    set ips [list]
    while {[gets $info line] != -1} {
        #scan $line "%s %s %s" ip user pass
        lappend ips $line
    }
    puts $ips
    close $info
    #轮询调用ssh
    -keygen foreach line $ips { scan $line "%s %s %s" ip user pass puts $ip
    #移到循环外面 spawn ssh
    -keygen -t rsa &>/dev/null spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $user@$ip #输入登录密码 expect { "(yes/no)?" { send "yes " expect "password:" { send "$pass " expect "*denied*"{puts "wrong pass"; exit 2} } } "password:" { send "$pass " expect "*denied*" {puts "wrong pass"; exit 2} } } }
  • 相关阅读:
    STL set
    STL pair
    STL简介
    最长公共子序列lcs
    MySQL常用内置函数整理
    MySQL注入点写webshell的五种方式
    phpAdmin写webshell的方法
    mysql之突破secure_file_priv写webshell
    MySQL提权之启动项提权
    MySQL提权之mof提权
  • 原文地址:https://www.cnblogs.com/missmzt/p/5909492.html
Copyright © 2011-2022 走看看