0

I'm trying to automate the process of transferring files from my remote server to my local directory using Python. I know of libraries like pysftp which are popular, but as far as I can tell these libraries require connections to be initiated from the local side (i.e. from a script that lives on the local machine). Is there a way to transfer files from a script that lives on the remote machine instead?

Thanks in advance.

Alan Wang
  • 153
  • 2
  • 9
  • Hi! you can PUT or GET files using SFTP. So, you can do the opposite: set your SFTP server at your local machine, create an SFTP client (your Python script) which can be running on your remote machine, and then use that client to send files (PUT) to your local machine. – Kalma Jan 13 '20 at 19:45
  • I see, thanks for the response. Sorry I'm a bit new to this. How do I find my host, password, and username on my local machine? – Alan Wang Jan 13 '20 at 19:51
  • 1
    well, this is off-topic in relation to Python. Anyway, Your host address, if you are on the same LAN than the server, will be something like 192.168.x.x (you can check using `ipconfig` from command-line on windows). If you are not on the same LAN, you can find your external IP Address calling ipify (see this: https://stackoverflow.com/questions/2311510/getting-a-machines-external-ip-address-with-python). For the user and password, I guess you can define them yourself when installing/configuring your SFTP server on your local machine! – Kalma Jan 13 '20 at 20:02
  • Appreciate it, thank you! – Alan Wang Jan 14 '20 at 00:38

0 Answers0