Privacy and Information Security | University of Illinois

SCP And SFTP For Unix And Mac OS

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.

Using SCP

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 (near and far) with the usernames this and that, respectively.

scp path/to/file

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

Note that you can also use SCP in reverse. If you want to transfer a file from far to near, you can type something like this:

scp /home/this/

If you need to copy an entire directory, you'll need to use the recursive flag, like this:

scp -r thisdirectory

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.

Using SFTP

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 ls, get, put, cd, and 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 near to far, get brings a file from far to 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 near to far.