系统环境:centos7
yum安装expect:yum -y install expect
#!/usr/bin/expect
spawn ssh root@192.168.44.131
expect {
"(yes/no)?" {send "yes\r";}
"password:" {send "123\r"}
}
expect "]#"
send "ifconfig\r"
send "exit\r"
expect eof
给予权限:chmod +x (脚本.sh)
执行:
[root@localhost shell]# ./exp.sh
spawn ssh root@192.168.44.131
root@192.168.44.131's password:
[root@localhost ~]# exit
登出
Connection to 192.168.44.131 closed.
yum安装vsftpd