msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

09 Jan 08 SFTP in batch mode

Posted by

This post describes how you use sftp in batch mode. If you don’t want to type in your password read my SSH without a password post.

Create a file named myCommands.sftp that contains the commands you want to run. My file looks like this

# Change to your desired directory locally
lcd /data/Hattori
# Change to the desired directory on the remote server
cd /backup
# Transfer all remote files locally
get *
# We're done with this session
bye

Next you run the sftp session

sftp -b myCommands.sftp example.com

That should be all that is necessary to download your files from the remote server.

This example could easily have been extended with a crontab entry.

Tags: , ,

Leave a Comment

You must be logged in to post a comment.