ssh 交互脚本
1.ssh交互
#!/bin/bash
passwd='123'
usradd="172.168.74.138"
/usr/bin/expect <<EOF
spawn ssh root@$usradd
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
expect "]#"
send "ifconfig\r"
send "exit\r"
expect eof
EOF

浙公网安备 33010602011771号