sftp Notes

sftp stands for secure file transfer program and can be used to move one or several files between machines on different networks. sftp encrypts the data during transfer and requires some form of authentication (usually a password or a public key) in order to open the session.

Usage / Syntax

sftp user@host[:/path]

Example

 
$> sftp kate@beeblebrox.big-uni.ca:/home/kate 

Connecting to beeblebrox.big-uni.ca...
kate@beeblebrox.big-uni.ca's password: 
Kate types in her password and, upon successful authentication, is rewarded with the sftp command prompt:
sftp>

Popular interactive commands

   ls     = list the current directory on the remote machine
   cd     = change directories on the remote machine
   mkdir  = make a directory in current directory on remote machine
   lls    = list the current directory on the local machine
   lcd    = change directories on the local machine
   lmkdir = make a directory in current directory on local machine
   get    = get files from the remote machine
   put    = put files on the remote machine
   mget   = get multiple files from the remote machine
   mput   = put multiple files on the remote machine
   help   = display commands available in sftp
mget and mput are superfluous however: you can use wildcards to select multiple files with put and get.

You end the sftp session by typing bye, quit or exit at the prompt.

sftp in action

Here is a sample session wherein I look at the files in the current remote directory, create a new subdirectory on the local machine, change to the new local subdirectory, get multiple files and quit the session:
 
sftp> ls
.
..
bday_invite.txt
bday_list
bday_confirmed.txt
bulk-mail
talks_master
testlist

sftp> lmkdir junk
sftp> lcd junk
sftp> get bday*
Fetching /home/kate/lists/bday_invite.txt to bday_invite.txt
/home/kate/lists/bday_invite.txt          100%  730     0.7KB/s   00:00
Fetching /home/kate/lists/bday_list to bday_list
/home/kate/lists/bday_list                100%  664     0.7KB/s   00:00
Fetching /home/kate/lists/bday_confirmed.txt to bday_confirmed.txt
/home/kate/lists/bday_confirmed.txt       100%  547     0.7KB/s   00:00
sftp> lls
bday_invite.txt
bday_list
bday_confirmed.txt
sftp> bye
$>
Check out the sftp man page for more exotic options and examples!