1

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?

MattUebel
  • 927
  • 4
  • 13
  • 32

2 Answers2

2

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" }

Nikolaidis Fotis
  • 2,032
  • 11
  • 13
  • 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
2

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.

BillThor
  • 27,737
  • 3
  • 37
  • 69