Forums

Programmatically copy files to remote

[reSOLVED ? -- see below. May not be "best" practice, but works]

I have to programmatically transfer .TXT files to a remote machine. What are best practices?


[EDIT]

Do this using rsync ssh. Setting public/private key will circumvent the need to type password. On your LOCAL machine

  1. bash the following line: ssh-keygen -t rsa

  2. Hit ENTER 3 times (set file location, passphrase, confirm passphrase)

  3. bash the following line: ssh-copy-id -i ~/.ssh/id_rsa.pub *userID*@ssh.pythonanywhere.com

You should now be able to run passwordless rsync. The rsync command looks like: rsync -avzhe ssh *userID*@ssh.pythonanywhere.com:/home/*userID*/*somefile* *LOCAL_DIRECTORY*

Once you know that it runs, create a script file on your LOCAL machine like this:

#!/bin/sh

rsync -avzhe ssh *userID*@ssh.pythonanywhere.com:/home/*userID*/*somefile* *LOCAL_DIRECTORY*

Save and CRON the script.

Perhaps a scheduled task / cronjob that just does a periodic rsync / sftp?

Yes yes, that's the idea. BUT not clear to me how to set up password less rsync/sftp.

Great! Glad you figured it out and also let us know in the edit above!