Open zking2000 opened 6 months ago
#!/bin/bash # 使用 expect 工具自动交互密码远程其他主机安装 httpd 软件 # 删除~/.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