1.安装expect模块
$ yum install -y expect
2.编写scp免密码登录脚本
$ vim /localshell/expect.sh
#!/usr/bin/expect
#expect.sh
#各院校应用备份同步一份到30.57,
set timeout 10
set src_file [lindex $argv 0]
spawn scp /home/backup/$src_file [email protected]:/home/backup/
expect "password:"
send "YBGybg123\r"
expect eof
3.运行脚本
$ /usr/bin/expect /localshell/expect.sh