Table of Contents

sftp command cheatsheet

login to sftp, using separate keyfile

$ sftp -i /home/ubuntu/.ssh/yourprivatekeyfile loginname@ssome.server.com
 
sftp>

create list of available files & folders on remote sftp

echo ls -alt | sftp someserver > somehost_available_files.txt
 
Connected to someserver.

download a file from sftp

echo get somefile.csv | sftp someserver

download a list of specific files from sftp

echo "ls -alt | grep ^someprefix_" | sftp someserver > somehost_available_files.txt
 
$ while read FILE; do echo "Downloading $FILE..."; echo "get $FILE" | sftp someserver; done < somehost_available_files.txt

download all files in the current folder from sftp

sftp hostaspersshconfig << EOF
get *
quit
EOF