Skip to content

Instantly share code, notes, and snippets.

@sithart
Last active June 14, 2024 13:44
Show Gist options
  • Save sithart/09bd877e8f293e09866cc041089dd6e1 to your computer and use it in GitHub Desktop.
Save sithart/09bd877e8f293e09866cc041089dd6e1 to your computer and use it in GitHub Desktop.
Upload file via pysftp with python
import pysftp as sftp
connection_info = {
'server': "SERVER NAME OR IP ADDRESS",
'user': "USER NAME",
'passwd': "PASSWORD",
}
def push_file_to_server():
s = sftp.Connection(host=connection_info['server'], username=connection_info['user'], password=connection_info['passwd'])
local_path = "LOCAL FILE PATH"
remote_path = "REMOTE FILE PATH"
s.put(local_path, remote_path)
s.close()
push_file_to_server()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment