Effective July 24, security.illinois.edu will redirect to techservices.illinois.edu/security/
SCP and SFTP for Unix, Linux, and Macintosh OS X
All Unix and Linux variants, as well as Mac OS X, include SCP/SFTP by default, making them very convenient to use.
Mac users will need to access the Terminal, found in Applications > Utilities. Alternatively, the University of Michigan's Research Systems Unix group offers Fugu (external link) as a free graphical SFTP client ( with "drag and drop" interface) for Mac OS X.
SCP is ideal for quick transfer of single files, such as email attachments. Syntax is similar to the Unix copy command. For demonstration purposes, we'll use two computers (
far) with the usernames
scp path/to/file firstname.lastname@example.org:path/to/destination
For example, if you want to transfer the file
example.txt from your home directory on
near to your home directory on
far, the command might look like this:
scp /home/this/example.txt email@example.com:/home/that/
Note that you can also use SCP in reverse. If you want to transfer a file from
near, you can type something like this:
scp firstname.lastname@example.org:/home/that/example.txt /home/this/
If you need to copy an entire directory, you'll need to use the recursive flag, like this:
scp -r thisdirectory email@example.com:/home/that/
Obviously, this system is a bit cumbersome for multiple file transfers. If you have a lot of work to do, such as web directory manipulation, you might want to use SFTP instead.
SFTP not as widely supported as SCP, but it's ideal if you don't remember the path to your target directory or if you have a lot of files to transfer. Begin by connecting to the remote computer:
You will be prompted for your username and password, after which you will be connected to the remote computer. Unlike the momentary SCP connection, which closes as soon as your file transfer is finished, your SFTP connection will remain open until you close it.
Now you're ready to begin transferring files. The five main SFTP commands are
lcd. These commands can be difficult to grasp conceptually. In essence,
get brings a file closer to you, while
put moves it farther away. The
cd command changes your remote directory, and
lcd changes your local directory. The
ls command displays the remote directory's contents. What makes these commands difficult is that they use the command window as a point of reference, not your physical location. If you open an SFTP connection from
get brings a file from
near. If you connect to
far via SSH, then open an SFTP connection to
near within that SSH window,
get will move a file from