How to copy a file to a remote server in Python using SCP or SSH? -


i have text file on local machine generated daily python script run in cron.

i add bit of code have file sent securely server on ssh.

if want simple approach, should work.

you'll want ".close()" file first know it's flushed disk python.

import os os.system("scp file user@server:path") #e.g. os.system("scp foo.bar joe@srvr.net:/path/to/foo.bar") 

you need generate (on source machine) , install (on destination machine) ssh key beforehand scp automatically gets authenticated public ssh key (in other words, script doesn't ask password).

ssh-keygen example


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -