expect实现ssh 免密登录
#!/usr/bin/expect
spawn ssh root@192.168.10.10
set timeout 10 //设置超时时间
expect "*password:"
send "nbc@123\r" //输入密码
expect {
"*yes/no" { send "yes\r"; exp_continue} //第一次ssh连接会提示yes/no,继续
"*password:" { send "$password\r" } //出现密码提示,发送密码
}
interact //交互模式,用户会停留在远程服务器上面.