实现方式:
通过expect工具实现
![](https://images2017.cnblogs.com/blog/491580/201710/491580-20171031153223136-1284866903.png)
#!/bin/bash
yum -y install expect
expect -c "
spawn scp -r root@192.168.10.106:/root/qumf/Agoly.txt /root/qumf/
expect {
\"*assword\"
{
set timeout 300;
send \"Hhly2017\r\";
}
\"yes/no\"
{
send \"yes\r\"; exp_continue;}
}
expect eof"