1. #!/bin/bash
    2. #删除~/.ssh/known_hosts 后,ssh 远程任何主机都会询问是否确认要连接该主机
    3. rm rf ~/.ssh/known_hosts
    4. expect <<EOF
    5. spawn ssh 192.168.4.254
    6. expect "yes/no" {send "yes\r"}
    7. #根据自己的实际情况将密码修改为真实的密码字串
    8. expect "password" {send "密码\r"}
    9. expect "#" {send "yum ‐y install httpd\r"}
    10. expect "#" {send "exit\r"}
    11. EOF