Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Usually, I use the scp command to transfer files on *nixes.

What's the difference between SFTP and SCP? Don't they both work on SSH?

share|improve this question
up vote 69 down vote accepted

In a nutshell, scp can only be used for transferring files, and it is non-interactive (i.e., everything has to be specified on the command line). sftp is more elaborate, and allows interactive commands to do things like creating directories, deleting directories and files (all subject to system permissions, of course), etc.

share|improve this answer
17  
Regarding interactivity: The difference you describe is about specific SFTP/SCP clients as implemented in OpenSSH. It's nothing about the protocols themselves. It's perfectly possible to implement interactive SCP client or non-interactive SFTP client. – Martin Prikryl Oct 8 '14 at 6:06

From Wikipedia:

Compared to the earlier SCP protocol, which allows only file transfers, the SFTP protocol allows for a range of operations on remote files – it is more like a remote file system protocol. An SFTP client's extra capabilities compared to an SCP client include resuming interrupted transfers, directory listings, and remote file removal. [1] For these reasons it is relatively simple to implement a GUI SFTP client compared with a GUI SCP client.

and

Although both SCP and SFTP utilize the same SSH encryption during file transfer with the same general level of overhead, SCP is usually much faster than SFTP at transferring files, especially on high latency networks. This happens because SCP implements a more efficient transfer algorithm, one which does not require waiting for packet confirmations. This leads to faster speed but comes at the expense of not being able to interrupt a transfer, so unlike SFTP, SCP transfer cannot be canceled without terminating the session.

share|improve this answer
10  
"SCP is usually much faster than SFTP at transferring files." – Micah Bolen Oct 4 '13 at 10:35
    
"But comes at the expense of not being able to interrupt a transfer". That's a pretty important trade-off. – aaaaaa Jun 25 at 1:42

From a purely command line perspective :

  • scp doesn't have an interactive mode nor can it read command scripts, that means everything must be written on the command line.
  • sftp has an interactive mode and can read commands from a file.

Other important difference between the 2 commands is that sftp cannot put a local file to a remote location using a single command line, although it can get remote file, while scp can do both.

sftp get remote file

sftp user@host:/path/to/remote.file [/path/to/local.file]

scp get remote file

scp user@host:/path/to/remote.file [/path/to/local.file]

scp put remote file

scp /path/to/local.file user@host:[/path/to/remote.file]
share|improve this answer
    
downvote? they be hatin. – codyc4321 Apr 26 at 0:03

SSH(Secure SHell) is a cryptographic network protocol to allow remote login and other network services to operate securely over an unsecured network.

SCP (Secure Copy Protocol) is a network protocol, which supports file transfers between hosts on a network. SCP uses Secure Shell (SSH) for data transfer and uses the same mechanisms for authentication.

SFTP(SSH File Transfer Protocol) is like a remote file system protocol. An SFTP client's extra capabilities include resuming interrupted transfers, directory listings, and remote file removal.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.