expect ssh免密码
脚本调用实现自动ssh输入密码登录
#!/usr/bin/expect
if {$argc < 2} {
send_user "usage: $argv0 src_file username ip dest_file password\n"
exit
}
set username "root"
set password "111111"
set src_file [lindex $argv 0]
set dest_file [lindex $argv 1]
set host_ip [lindex $argv 2]
set timeout 50
spawn scp -r $src_file $username@$host_ip:$dest_file
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword:" {send "$password\n"}
}
"*assword:"
{
send "$password\n"
}
}
expect "100%"
expect eof