zoukankan      html  css  js  c++  java
  • 自动登录服务器 expect

    ssh179

     1 #! /usr/bin/expect                                                                                                 
     2 set timeout 60
     3 set host 172.20.106.179
     4 set name [lindex $argv 0]
     5 set password abc123
     6 spawn ssh $name@$host 
     7 expect {
     8     "(yes/no)?" {
     9         send "yes\n" 
    10         expect "password"
    11         send "$password\n"
    12     }
    13     "password" {
    14         send "$password\n"
    15     }
    16 }
    17 interact

    ssh53

     1 #! /usr/bin/expect                                                                                                 
     2 set timeout 60
     3 set host 172.20.106.53
     4 set name [lindex $argv 0]
     5 set password abc123
     6 spawn ssh $name@$host 
     7 expect {
     8     "(yes/no)?" {
     9         send "yes\n" 
    10         expect "password"
    11         send "$password\n"
    12     }
    13     "password" {
    14         send "$password\n"
    15     }
    16 }
    17 interact

    ssh143

     1 #! /usr/bin/expect                                                                                                 
     2 set timeout 60
     3 set host 172.20.106.143
     4 set name [lindex $argv 0]
     5 set password abc123
     6 spawn ssh $name@$host 
     7 expect {
     8     "(yes/no)?" {
     9         send "yes\n" 
    10         expect "password"
    11         send "$password\n"
    12     }
    13     "password" {
    14         send "$password\n"
    15     }
    16 }
    17 interact
  • 相关阅读:
    PHP入门
    requests中text,content,json之间的区别
    有关pip报错的问题

    pycharm操作
    python selenium 相关操作
    python tkinter菜单
    初识Go
    Python _easygui详细版
    easygui _1
  • 原文地址:https://www.cnblogs.com/openix/p/3120082.html
Copyright © 2011-2022 走看看