Using sftp secure file transfer protocol

Reviewed by Bil Hays 5/2/14

Campus security rules wisely require that we use sftp (Secure File Transfer Protocol) instead of ftp.  sftp is an extension of the ssh protocol suite and functions exactly like a regular ftp client with the major difference being that all communication is encrypted.

ftp is no longer supported on our systems, with the exception of anonymous ftp, which is supported in a limited way on ftp.cs.unc.edu.  (See our article on anonymous ftp.)

Computer Services recommends the use of the SSH Secure Shell client for SFTP as your sftp client on Windows.   SSH Secure Shell includes support for SSH2 and SFTP2.  This client is free for educational usage and versions for various flavors of Windows may be downloaded from shareware.unc.edu.

Standard versions of Linux include command line support for sftp.

Macintosh OS 10.1.3 and higher includes command line support for sftp through the Terminal window, but you should also take a look at fugu, a nice GUI sftp client.

Basic and interactive commands are listed below.  Email us at help@cs.unc.edu if you have questions.

Basic commands

sftp [-vc] [-b batchfile] [-o ssh_option] [host]

sftp [[user@]host[:file[file]]]

sftp [[user@]host[:dir[/]]]

Interactive commands

cd path Changes remote directory to path.

lcd path Changes local directory to path.

chgrp grp path Changes group of file path to grp.  grp must be a numeric GID.

chmod mode path Changes permisssion of file path to mode.

chown own path Changes owner of file path to own.  own must be a numeric UID.

exit Quits sftp

get remote-path [local-path] Retrieves the remote-path and stores in on the local machine.  If the local-path name is not specified, it is given the same name that it has on the remote machine.

help Displays help text.

lmkdir path Creates local directory specified by path.

ln oldpath newpath Creates a symbolic link from oldpath to newpath.

lpwd Prints local working directory.

ls [path] Displays remote directory listing of either path or current directory (if path is not specified).

mkdir path Creates remote directory in location specified by path.

put local-path [remote-path] Uploads local-path and stores it on the remote machine.  If the remote-path name is not specified, it is given the same name as it has on the local machine.

pwd Displays remote working directory.

quit Quits sftp

rename oldpath newpath Renames remote file from oldpath to newpath.

rmdir path Removes remote directory specified by path.

rm path Deletes remote file specified by path.

symlink oldpath newpath Create a symbolic link from oldpath to newpath.