University of Southern California

ITS Information Technology Services

A division of the Office of the Chief Information Officer

SFTP Using Command Line (UNIX, Mac OS X)

This page contains instructions on how to transfer files between two computers connected to the Internet using the SFTP utility in UNIX. This utility allows you to transfer both ASCII and binary files between computers quickly and efficiently.

Getting Started

Before you can perform any action using the SFTP utility, you must connect and log in to the remote host (the computer or server you wish to transfer files to or from).

To log in to the remote host:

  1. Bring up a UNIX prompt and type sftp USC username@usc-host.
  2. Use your USC username and password to log in to the remote host. The sftp> prompt displays.

Issuing Commands on the Remote and Local Hosts

Use standard file and directory UNIX commands at the sftp> prompt. For example, on the remote host, you can use ls to get a listing of the current directory, ls -l to get a long listing, or cd to move to a different directory.

To issue commands on the local host (your computer), use standard file and directory UNIX commands as when you are issuing commands on the remote host. However, you will need to begin each command with an exclamation mark (!). Your starting local or working directory is specified as the default incoming and outgoing directory.

If you want to receive files in, or send files from, a directory other than your starting working directory, you will need to specify the directory. For example, if you want to download all files to a folder called INCOMING on your local directory, you first have to create that folder with the ! mkdir UNIX command, and then you need to use the lcd command to change to that new folder. Here is the syntax for this example:

For a more detailed explanation of other UNIX commands, visit UNIX Commands and Utilities.

Using Command Line for SFTP

To download a file from a remote host:

  1. Once you are pointing to the correct directory on the remote host, use the get command to copy a file to the local directory (on your computer).
  2. Type get filename at the sftp> prompt, and then press Enter.
  3. The file is copied to your local directory.

To upload a file to a remote host:

  1. Once you are pointing to the correct directory on the remote host, use the put command to copy a file from the local directory (on your computer).
  2. Type put local-path-to-file remote-path at the sftp> prompt, and then press Enter.
  3. The file is copied to the remote host.

To quit SFTP:

  1. At the sftp> prompt, type quit.
  2. The connection closes, and you return to the UNIX prompt.

To get help:

  1. At the sftp> prompt, type ?. A list of all available commands will display.
  2. At the sftp> prompt type ? <command>. This will return brief information on that particular command.

Getting Help

If you have SFTP-related questions, please call the Customer Support Center at 213-740-5555 or email consult@usc.edu.

Last updated:
February 01, 2011

SFTP Documentation

The use of all USC computing resources is governed by the USC Computing Policies.