#!/bin/bash
#删除~/.ssh/known_hosts 后,ssh 远程任何主机都会询问是否确认要连接该主机
rm -rf ~/.ssh/known_hosts
expect <<EOF
spawn ssh 192.168.4.254
expect "yes/no" {send "yes\r"}
expect "password" {send "密码\r"}
expect "#" {send "yum -y install httpd\r"}
expect "#" {send "exit\r"}
EOF
转载于:https://www.cnblogs.com/luwei0915/p/10514469.html