SCP on cronjob without asking/prompting password

How to copy a file with SCP and cronjob for a external location and cronjob – server -.

#!/usr/bin/expect -f
# connect via scp
 spawn scp "/location/file.ext" "username@host:/location/file.ext"
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "password\r"
}
}
interact

wait
sleep 2s
ls

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.