1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/expect
#good on new kali  这个在新的kali 上是ok的
set timeout 30
set sshIP "4.88.1.2"
set keypassword "ZdvV"
set rootPassword "5D"
#spawn ssh -o StrictHostKeyChecking=no -i /root/key  [email protected]$sshIP
expect "Enter passphrase"
send "$keypassword\r"
expect "]$"
send "sudo -i\r"
expect "xxxxx"
send "$rootPassword\r"
expect "]#"
## run command
#send "cat /root/1  && echo 'test was ok .';exit\r"
#send "bash /data/tmp/dbins   && echo 'dbins  was ok.';exit\r"
#expect "52wan"
#send "exit\r"
#expect eof {exit 0}
interact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/expect
# on old kali  这个在老的kali
set timeout 30
set sshIP "4.88.1.2"
set keypassword "Zd"
set rootPassword "5D"
spawn ssh -o StrictHostKeyChecking=no -i /home/key  [email protected]$sshIP
expect "Enter passphrase"
send "$keypassword\r"
expect "52wan"
send "sudo -i\r"
expect "password for 52wan:"
send "$rootPassword\r"
expect "]#"
## run command
#send "cat /root/1  && echo 'test was ok .';exit\r"
#send "bash /data/tmp/dbins   && echo 'dbins  was ok.';exit\r"
#expect "52wan"
#send "exit\r"
#expect eof {exit 0}
interact