-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssh4gfw.sh
executable file
·51 lines (48 loc) · 1.76 KB
/
ssh4gfw.sh
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
#!/usr/bin/expect -f
# 可能需要先 sudo apt-get install expect
# from http://blog.chinaunix.net/space.php?uid=20302630&do=blog&cuid=365812
set timeout 30
set user "username"
set passwd "passwd"
set server "server"
spawn /usr/bin/ssh -CNg -qnf -D 7070 $user@$server
expect {
#"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
#interact {
#timeout 30 { sent " " }
#}
#send "exit\r"
##!/usr/bin/expect -f
## Expect script to supply root/admin password for remote ssh server
## and execute command.
## This script needs three argument to(s) connect to remote server:
## password = Password of remote UNIX server, for root user.
## ipaddr = IP Addreess of remote UNIX server, no hostname
## scriptname = Path to remote script which will execute on remote server
## For example:
## ./sshlogin.exp password 192.168.1.11 who
## ------------------------------------------------------------------------
## Copyright (c) 2004 nixCraft project <http://cyberciti.biz/fb/>
## This script is licensed under GNU GPL version 2.0 or above
## -------------------------------------------------------------------------
## This script is part of nixCraft shell script collection (NSSC)
## Visit http://bash.cyberciti.biz/ for more information.
## ----------------------------------------------------------------------
## set Variables
#set password [lrange $argv 0 0]
#set ipaddr [lrange $argv 1 1]
#set scriptname [lrange $argv 2 2]
#set arg1 [lrange $argv 3 3]
#set timeout -1
## now connect to remote UNIX box (ipaddr) with given script to execute
#spawn ssh root@$ipaddr $scriptname $arg1
#match_max 100000
## Look for passwod prompt
#expect "*?assword:*"
## Send password aka $password
#send -- "$password\r"
## send blank line (\r) to make sure we get back to gui
#send -- "\r"
#expect eof