I've been using pysftp to successfully transfer files from a remote server to a local server. Here's what the simple version of my code looks like:
class SftpClass(object):
def __init__(self):
self.sftp = None
def connect_to_sftp(self, sftp_host, sftp_username):
# initiate SFTP connection
self.sftp = pysftp.Connection(sftp_host, sftp_username)
def sftp_get_file(self, local_directory, remote_directory, file):
# pull file from remote directory and send to local directory
self.sftp.get(file in remote_directory, file in local_directory)
This works because my local and remote directories are both on the same linux server. But what if they remote directory was on a different server? How can I make sure the script would still run and successfully transfer files from the separate remote server to my personal remote server?