zoukankan      html  css  js  c++  java
  • expect --批量传递公钥

    #!/binbash
    ! rpm -qa |grep expect &> /dev/null && yum -y install expect   #判断是否已下载expect 若没有则下载该服务
    if [ ! -e /root/.ssh/id_rsa.pub ];then                 #判断公钥是否已存在 没有则生成 /usr/bin/expect <<EOF set timeout 10 spawn ssh-keygen expect "id_rsa" send " " expect "passphrase" send " " expect "agian" send " " expect eof EOF fi while read file;do                     #遍历文件(ip 密码) ip=`echo "$file" |awk '{print $1}'`      #截取出ip passwd=`echo "$file" | awk '{print $2}'`   #截取出密码 /usr/bin/expect <<EOF set timeout 5 spawn ssh-copy-id -i $ip expect { "yes" { send "yes "; exp_continue } "$ip" { send "$passwd " } } expect eof EOF done < /root/host_name                   #保存ip 密码的文件路径 可自定义

    cat /root/host_name

    192.168.198.150    xxxxxxx
    192.168.198.151    xxxxxxx
    192.168.198.152    xxxxxxx
    192.168.198.153    xxxxxxx
    ......
  • 相关阅读:
    oracle 用户 权限
    oracle move 释放 表空间
    oracle 视图 参数
    js 、c# 编码解码
    Oracle实体化视图
    简单工厂VS工厂方法
    面向对象——(9)封装和接口
    写给明天的软件工程师——(转)
    设计模式简介
    设计模式的六大原则
  • 原文地址:https://www.cnblogs.com/Xinenhui/p/13916228.html
Copyright © 2011-2022 走看看