使用expect工具自动交互密码远程其他主机安装httpd软件-《shell脚本》

admin 2025-11-06 14:25:59 系统网络 来源:ZONE.CI 全球网 0 阅读模式
    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
    01-shell脚本介绍-《shell脚本》 系统网络

    01-shell脚本介绍-《shell脚本》

    一、shell脚本是什么二、为什么要学shell,而不是其他计算机语言三、学习这门课程的优势四、学了能干什么五、学习什么内容六、学习的技巧七、成长路径八、学习环
    评论:0   参与:  9