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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -