Skip to content

Commit dd37cff

Browse files
forcoderforcoder
authored andcommitted
update autossh
1 parent 906bc62 commit dd37cff

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

shell/autossh.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/bin/expect -f
22

3-
set PASSWORD "password\r"
4-
set IP "IP"
3+
set timeout 15
4+
set ip [lindex $argv 0]
5+
set PASSWORD "*******"
6+
7+
spawn /usr/bin/ssh qiaozhou@$ip
8+
expect {
9+
timeout { send_user "Timeout."; exit 1 }
10+
"*password:" { send "$PASSWORD\r"; exp_continue }
11+
"*~]$ " { send "sudo su admin\r"; exp_continue }
12+
"*Password:" { send "$PASSWORD\r"; exp_continue }
13+
"*]$ " { }
14+
}
515

6-
spawn /usr/bin/ssh qiaozhou@$IP
7-
expect "*password:"
8-
send "$PASSWORD"
9-
expect "*~]$ "
10-
send "sudo su admin\r"
11-
expect "*Password:"
12-
send "$PASSWORD"
13-
expect "*]$ "
1416
interact

0 commit comments

Comments
 (0)