Skip to main content

SFTP - Secure File Transfer Protocol

'Sftp' is a secure version of the File Transfer Protocol (ftp). It uses FTP commands to transfer files securely between accounts, whether the accounts are on the same machine or on different machines, including your home computer, if it is properly configured.

List of SFTP Commands

To transfer a file you must know the machine name (e.g. mi5.ucsd.edu), and the name and password of the account with which you want to copy files.

Getting started with sftp:

Let's say you were on your account "jbond" and you wanted to transfer a file to an account drno on mi5.ucsd.edu. First, you should start sftp and tell it to which username and machine you want to hook up:

	% sftp drno@mi5.ucsd.edu
	

If this is the first time you have connected to the remote machine, mi5.ucsd.edu, a security warning message will be displayed:

	Connecting to mi5.ucsd.edu...
	The authenticity of host 'mi5.ucsd.edu (127.0.0.1)' can't be established.
	RSA key fingerprint is e4:16:3a:3f:69:b6:37:69:69:ca:bb:a6:33:fa:47:ac.
	Are you sure you want to continue connecting (yes/no)?
	

Type 'yes', and hit return. The remote machine will warn you that it now regards mi5.ucsd.edu as authentic, and then asks you for drno's password.

	Warning: Permanently added 'mi5.ucsd.edu' (RSA) to the list of known hosts.
	drno@mi5.ucsd.edu's password: 
	

If the account and password are correct, then the sftp prompt ( sftp> ) will appear:

	sftp>
	
How to get a single file from the remote account:

To copy a file from the remote account to your original acount, use the "get" command followed by the name of the file you want to copy:

	sftp> get martini.txt
	
How to put a single file into the remote account:

To copy a file from your original account into the remote account, use the "put" command followed by the name of the file you want to copy:

	sftp> put shaken-not-stirred.txt

	
Some other useful sftp commands:

You are initially logged into the home directory of the remote account. It is possible to change to a different directory on the remote account using the "cd" command, just like in Unix:

	sftp> cd mydirectory
	

The "ls" command may be used to list the contents of the current directory on the remote machine.

	sftp> ls

	

Alternatively, "ls -l" can be used to obtain a more detailed listing, showing the file's access privilages, size, and the date it was last modified.

A list of sftp commands is available within ftp by typing the word "help" or a question mark (?) at the prompt:

	sftp> help
	

To exit the ftp program, type the command "quit" at the ftp prompt.

	sftp> quit
	%
	
Copying multiple files

To copy multiple files, use wildcard characters to specify many files. A 'wildcard' character is a punctation mark that represents any character, or any number of any characters. An asterisk '*' represents any number of any characters, and a question mark '?' represents one of any character.

	sftp> get *
	
Additional information:

For more information on sftp, see the manual page for sftp:

	% man sftp
	

List of SFTP Commands

While the version of SFTP that you are using will vary from machine to machine, here are some of the common commands, along with a brief definition