We even use it within our LAN for obtaining ascii and binary files. This article attempts to give an overview of how the protocol works and also point out why this protocol creates problems with modern Internet realities like NAT and firewalls.
FTP is an application layer protocol layered on top of TCP. It uses TCP port number 21. But that is not all. Unlike any other protocol, it uses TCP port number 20 at which it listens for incoming connections. The TCP connection to port 21 of the FTP server is the command channel. And whenever you list files or transfer files back and forth, a brand new TCP connection is established from the FTP server to the FTP client machine. This is called the data channel.
All this complexity of two TCP connections and inbound connections serve no purpose. We could jolly well have used one single connection both for data and commands.
Today we are familiary with the marvellous ssh program which multiplexes several TCP and X11 connections over a single TCP connection to port 22. Anyway it is impossible to change FTP now. It is too old and widespread to even attempt such a thing. But in spite of this overly complex design, the protocol does perform well and is quite efficient in doing its job of transferring files from and to a remote machine on the Internet.
Here is a pictorial representation of the FTP protocol.
As you can see, I was referring to the active mode of FTP above. Today many servers support passive mode FTP in which an inbound connection is avoided. People hate someone connecting from outside. And firewalls certainly will not allow.
This brings us to the topic of FTP and firewalls. There is a thrid party server to server transfer mode in FTP in which you can transfer files between two FTP servers. As you can see, this complicates FTP interactions even further and from the security point of view , FTP is perhaps the most dangerous protocol. Did I tell you that the username and password are sent in the clear?
Like all protocols FTP has evolved over time, but the core remains the same. Today NAT devices also detest FTP protocol as they have to specially handle the incoming FTP connection in active mode.
With all this FTP is here to stay. Even with extremely robust p2p protocols like bittorrent in today's Internet landscape, FTP will continue to be used for transferring files.
Files are sent in the clear of course. And there is no support for integrity checking. There are extensions which support many things.
sftp, the companion program of ssh gives a FTP like interface. But internally it is completely different. Not only is it secure, as it is encrypted with sound authentication mechanisms, the wire protocol also is completely different.
There are secure alternatives to FTP which add an SSL layer below. But given the nature of the protocol as I have talked in enough detail above, this is not trivial.
File transfer in today's Internet and future is not going to be client server. With VoIP and other person to person communcations gaining ground, files will be shared in different ways and p2p model will win in the end. This ensures redundancy, better bandwidth utilization and is a form of fault tolerant distributed computing.
There are popular FTP clients and servers in the linux world some of which are certainly worth mentioning. pure-ftpdproftpdncftplftpare some examples. ncftp comes with ncftpget and ncftpput which take the URL format for passing username and password. I shall give an example that can help you started. This can help you script FTP easily. $ ncftpget ftp://user:password@server:/dir/file