Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I used to think SCP is a tool to copy files over SSH, and copying files over SSH is called SFTP, which is itself a synonym to FISH.

But now as I was looking for a Total Commander plugin to do this in Windows, I've noticed that on its page it says "Allows access to remote servers via secure FTP (FTP via SSH). Requires SSH2. This is NOT the same as SCP!".

If it's not the same then what am I misunderstanding?

share|improve this question
4  
This is an extension of a previous question. (@Ivan: it would have been helpful to mention this.) –  Gilles Mar 7 '11 at 0:39
add comment

4 Answers

up vote 18 down vote accepted

SFTP isn't the FTP protocol over ssh, but an extension to the SSH protocol included in SSH2 (and some SSH1 implementations). SFTP is a file transfer protocol similar to FTP but uses the SSH protocol as the network protocol (and benefits from leaving SSH to handle the authentication and encryption).

SCP is only for transferring files, and can't do other things like list remote directories or removing files, which SFTP does do.

FISH appears to be yet another protocol that can use either SSH or RSH to transfer files.

share|improve this answer
    
Worth adding: there's also FTPS, which is FTP over TLS. –  mikemaccana Feb 24 at 12:37
    
@mikemaccana you can then add FTPES witch is the possibility to use ftps explicitly over a regular ftp connection –  Kiwy Feb 24 at 12:39
add comment

The SSH protocol creates a secure tunnel through which you can transfer a bidirectional stream, and you can use that stream to connect any two processes you like.

The most familiar two processes would be a shell (at the server) and an interactive terminal emulator (at the client). That's what you're using when you ssh to a server and type commands at the remote shell's prompt.

SCP is file transfer done using only that shell and a remote command. In SCP, once the client is connected to the server, and all the authentication and authorization has been done, the client sends the remote shell a command like scp -f myfile.txt, which just writes the contents of the file myfile.txt to the stream (for the client to read) or scp -t myfile.txt which reads from the stream and writes to myfile.txt.

You'll not that -f and -t (for "from" and "to") are not in the scp manpages. They are considered internal. There is a lightweight acknowledgement scheme, and a scheme for transferring directories by wrapping the file contents in simple headers. But for the most part SCP is a basic matter of writing the bytes of the file onto the SSH tunnel, letting SSH deal with complicated stuff like compression and integrity.

SFTP is a much more complex file transfer protocol, which again is tunnelled through SSH.

In SFTP both requests and responses are binary-encoded packets with names like "SSH_FXP_OPEN", "SSH_FXP_STAT", "SSH_FXP_READ", "SSH_FXP_DATA", "SSH_FXP_CLOSE".

One interesting feature of the protocol is that commands can be pipelined, and responses may come in any order. This can mean that sessions spend less time waiting on responses, and there are opportunities to optimise concurrent transfers from one server with data-sources of various speeds -- although I don't know to what extent those opportunities have been taken.

SFTP has commands to do many things that SCP doesn't address; like delete, rename, truncate, move, etc.

All the details are available in an IETF Draft.

It's worth noting that newer SSH packages replace the user scp binary with a symlink to the SFTP binary. This SFTP has the look and feel of scp, but under the covers it's using the SFTP protocol.

Fish is an interesting piece of history. Let's say you want to transfer files over SSH, but your remote system doesn't have SCP. Or perhaps you want to do more sophisticated file operations than SCP, but your remote system doesn't have SFTP. Neither of those scenarios are likely today, but when Fish was invented, they were.

So the developers of the client Midnight Commander set about creating their own solution. It's similar to scp in principle, but there are more commands. The client sends commands that look like:

 #RETR /some/name
 ls -l /some/name | ( read a b c d x e; echo $x ); echo '### 100'; cat /some/name; echo '### 200'

If you're talking to a Fish server, then it will interpret the #RETR command. However if the remote server doesn't have a Fish server installed, the commands will be interpreted by the shell. First a comment, then a command which prints info about the file, followed by the file contents surrounded in some markers.

Effectively, in the absence of scp or fish, the client has "rolled its own" scp equivalent - but it can equally send shell commands to rename, move, truncate, etc.

Details of Fish are in the Midnight Commander source here.

What does this all mean from an end-user perspective?

  • older SSH server implementations support scp but not SFTP; you can't use an SFTP client with these
  • Use SFTP for performance, reliability and flexibility
  • Your "scp" client might be an SFTP client in disguise
  • Fish might be useful in niche circumstances, but otherwise use the more standard SFTP.
share|improve this answer
add comment

Put it simple:

SFTP = SSH + SFTP-server on server
SCP  = SSH + `scp` on server side
FISH = SSH + `dd` (and some other basic Unix utilities on the server side only) 
share|improve this answer
    
But sftp and scp requires special programs on the server side, unlike FISH, which uses only basic Unix utuilities in the remote shell. –  imz -- Ivan Zakharyaschev Dec 17 '12 at 18:00
    
According to the description of FISH,a remarkable feature of FISH is that it doesn't require something special on the remote side (no server program, like scp for scp or sftp-server). And there're cases indeed when the remote side is a "restricted" Unix, where you can't install what you want: for transferring files to Android through SSH (over WiFi), I've written the set of rpush-cat scripts -- perhaps, a FISH client would work. (tramp-fish.el in Emacs could, too: the regular TRAMP client didn't work because stat wasn't there on Android.) –  imz -- Ivan Zakharyaschev Dec 18 '12 at 13:02
add comment

FISH and SFTP are similar, and as observed do both work over SSH, SFTP requires specific support and configuration in the SSH Server to facilitate the transfer, but it a bit more secure and allows for SysAdmins to only allow SFTP (in these situations FISH won't work).

FISH requires a shell (sh/rsh for instance) to copy, and hence requires full SSH access to the machine, I would imagine it would be harder to secure (I cannot comment objectively on this as I've never had to).

Where possible, I'd recommend SFTP, scp, FISH (in that order).

Wikipedia FISH Article

share|improve this answer
    
According to the linked description, a remarkable feature of FISH is that it doesn't require something special on the remote side (no server program, like scp for scp or sftp-server). And there're cases indeed when the remote side is a "restricted" Unix, where you can't install what you want: for transferring files to Android through SSH (over WiFi), I've written the set of rpush-cat scripts -- perhaps, a FISH client would work. (tramp-fish.el in Emacs could, too: the regular TRAMP client didn't work because stat wasn't there on Android.) –  imz -- Ivan Zakharyaschev Dec 18 '12 at 13:01
add comment

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.