-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_go.exp
executable file
·56 lines (52 loc) · 1.06 KB
/
auto_go.exp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/expect -f
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
set host [lindex $argv 0]
set port [lindex $argv 1]
set user [lindex $argv 2]
set password [lindex $argv 3]
set secret [lindex $argv 4]
set s_host [lindex $argv 5]
set s_user [lindex $argv 6]
set s_password [lindex $argv 7]
set timeout 20
spawn ssh -p $port $user@$host
match_max 100000
expect {
"*没有资产*" {
# 命中此部分,则终止匹配,交由用户介入
}
"*password:"
{
send -- "$password\n";exp_continue
}
"*passphrase*"
{
send -- "$password\n";
}
"continue connecting"
{
send -- "yes\n";exp_continue
}
"MFA auth"
{
set oath [exec python3 ./auth.py $secret]
send -- "$oath\n";exp_continue
}
"Opt>"
{
send -- "$s_host\n";exp_continue
}
"ID>"
{
send -- "$s_user\n";exp_continue
}
"Last login"
{
# send -- "echo 'Welcome to '`hostname`'. Enjoy with sshgo...'\n"
}
}
interact