I need to connect to multiple SFTP connections and copy files to my system.

I will maintain one CSV file in our local system. It will have multiple partners' information of username, password, hostname, port, and inbox folder path.

ex : partner1 | user1 | password1 | hostname1 | port1 | inbox path| outbox path| 
     partner2 | user2 | password2 | hostname2 | port2 | inbox path| outbox path|

In my Unix script, I need to prepare SFTP commands, to login into partner1's SFTP connection and get all the files and move into outbox path. Once partner one's file transfer completes, the script should prepare the next partner's SFTP commands for the file move.

How to set SFTP command in script?

ssh -oport username@hostname   --> after that how to set password command 

NOTE: Some partners have privatekey based authentication and some have public based authentication. How to implement logic in script for these private and public key based authentication.


I recommend you use lftp, which is specifically designed for scripted SFTP sessions, amongst other things.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.