用法:expect autossh 192.168.67.251
set username root
set password 123sh
if { $argc != 1 } {
puts "usage autossh
"
exit 0;
}
set sshkey 1
spawn ssh -t $username@[lindex $argv 0]
expect "*(Yes/no)*"
send "yes\r"
set sshkey 1
expect "*Password:*"
send "$password\r"
set sshkey 0
expect eof
puts "eof"
if {$sshkey != 1} {
expect "*Password*"
{ send "$password\r" }
}
阅读(336) | 评论(0) | 转发(0) |