Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to create a script that would execute a series of scp commands. This would pull a specific set of files from another computer on the network to a specific directory on the local machine.

What are the authentication considerations of note? I.E. this will end up being a cron job, so what would be the best way to handle the password challenges?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

you can handle the password either by using authorized_keys (ssh-keygen , ssh-copy-id) which is more "automated" an you don't ger prompted for password

The other way is to use expect, which "autofills" the password field (a little configuration is needed) {and generally it works like ... "when you see password field give this password" }

share|improve this answer
2  
key-based auth is probably the easiest/safest, and also will save you from having to store your passwords in the script itself. –  Sweet Aug 16 '10 at 18:53

I would seriously consider using rsync to transfer the files. It will avoid copying the files it the haven't changed, and only pull changes if the file has been changed. This saved me lots of bandwidth and time pulling log files.

rsync can be run as a server on the remote end, or run over ssh.

I would suggest using key-based authentication which ever option you choose.

share|improve this answer
    
I would use this method too. Rsync is a great protocol and works well with SSH Keys. –  vmfarms Aug 17 '10 at 15:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.