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 root@192.168.30.57:/home/backup/ expect "password:" send "YBGybg123 " expect eof
3.运行脚本
$ /usr/bin/expect /localshell/expect.sh