Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications

The file transfer protocol in short known as FTP has been around sincethe early days of the Internet. And several decades hence, even todayftp is a common way of downloading files from the Internet.

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

Have fun!

Rate This Article: poor excellent
Comments about this article
Nice one
writen by: S.Ajesh kumar on 2007-09-18 22:11:46
Dear girish, the article on Ftp is a useful one .why don't u cover some of the security features of Ftp in Linux systems.Hope that u would surely give it in future.I think in most of the linux machines if u login remotely as root(ftp),u can access all the areas of the system.isnt it? how to protect it? Ajesh
RE: Nice one written by S.Ajesh kumar:
Nice one
writen by: Thaha on 2007-09-19 06:10:07
thanks for such a nice article.
RE: Nice one written by Thaha:
Test Engineer
writen by: Geanthy on 2007-09-19 07:27:42
Keep publishing articles like this for us newbies
RE: Test Engineer written by Geanthy:
writen by: NeonGen on 2007-09-22 13:01:32
This article gave me some inside thx
RE: THX written by NeonGen:
more on ftp
writen by: Andrei Stoleru on 2007-10-07 12:23:18
Hi Nice tutorial. This reminds me: I'm trying to write a ftp client in Flex (with the new socket class in as 3.0), any idea where I can read about all the commands/responses from a ftp serve? Thanks ;)
RE: more on ftp written by Andrei Stoleru:
help needed
writen by: mahesh on 2007-10-10 12:34:05
RE: help needed written by mahesh:
Difference between FTP payload Data and
writen by: Irfan Ahmed on 2007-11-06 06:14:00
what is the difference between simple FTP payload data and chopping a file into payload size. Both contains same data. do FTP changes data in any means during the transfer which later handles in application or transport layer.
RE: Difference between FTP payload Data and written by Irfan Ahmed:
Linux Noob
writen by: X-Modius on 2007-11-16 08:41:18
Informative article. Perhaps you could next go into more depth on SFTP with SSH. Hooray for OpenSSH.com, a free download of the secure SSH daemons for creating your own secure FTP site. :) No I'm not from the group, but I'm a noob and found it easy to set up (in Windows). Please don't stone me. :) Linux is next.
RE: Linux Noob written by X-Modius:
writen by: John on 2007-12-02 00:35:34
Thank you for nice article! :) In addition to the clients that you listed don't you know anything about linux ftam ftp client working over IP networks? There are some implementations but rather old and I can't get it working (contacts to authors don't work any more etc.). Any information incl. contacts are highly appreciated. Thank you so much.
RE: consultant written by John:
networking doubt
writen by: ravikumar on 2008-04-08 14:24:08
hi iam ravi kumar i had a doubt on checksumming a packet.. can i have your mail id to which i can contact with my doubt..
RE: networking doubt written by ravikumar:
i want to know about file transferring i
writen by: vinod kumar on 2008-07-01 08:34:30
so,please give me suggestion to implement an ftp,tftp.what are the requirements for that implementation.
RE: i want to know about file transferring i written by vinod kumar:
writen by: khabat on 2008-11-26 01:37:18
RE: FTP written by khabat:
For More Detail visit here
writen by: shubhy3269 on 2009-02-25 00:36:23
For More Detail visit here http://www.mastersmindtechnologies.com/foodszone
RE: For More Detail visit here written by shubhy3269:
i want some specific applications
writen by: askpavanasks on 2009-07-13 23:54:56
Girish, could u mind to write some specific applications which tell ftp's behavior rather than pictures. Because I need some detailed idea about what exactly u want say about ftp and its security...
RE: i want some specific applications written by askpavanasks:
FTP Sever
writen by: Pashy on 2010-05-20 04:25:06
I have installed a FTP Server on my Linux machine (Fedora 11).
My manager wants the ftp users to be restricted to their own home dir using sftp.
But the said condition is met when the user logs in using ftp over port 21 and when
the user logs in using sftp i.e. protocol 22, he/she has readable (downloadable) access
to the upper dir's as well. In short the user is able to traverse through file system using
sftp. I have chrooted the users as well.

Could you please advice me the reason
RE: FTP Sever written by Pashy:

Comment title: * please do not put your response text here