1.先用ssh root@192.168.88.132 连接主机,后退出。
2.然后运行脚本 rj.sh
/usr/bin/expect <<EOF set timeout 30 spawn ssh -l root 192.168.88.132 "useradd lilei" expect "password:" send "123 :" spawn ssh -l root 192.168.88.132 "yum install nmap -y" expect "password:" send "123 :" expect eof EOF useradd lilei ~