FTP? Gearhead's here for you
A reader wrote: "Sure I know what FTP does from a user's point of view, but how does it actually do it?" That is a fine question.
FTP has a long and illustrious history. It first appeared as an Internet Engineering Task Force RFC 114 in 1971. Curiously, today RFC 114 doesn't appear to be anywhere on the 'Net!
But for all the current FTP request for comments that actually are on the 'Net, go to www.rfc-editor.org/cgi-bin/rfcsearch.pl and enter "FTP" as the search term. And the key RFC for FTP is RFC 959 written in 1985.
FTP is a protocol designed to let data be transferred from one computer to another. It is a client-server system and, depending on the client's rights, files may be sent to or retrieved from the server, directories created, listed or deleted and file attributes modified.
Advertisement: |
The process required to transfer files involves three steps: 1. The client connects to the server and is authenticated (anonymous access may be allowed); 2. The client sends commands that may include listing and modifying directories as well as carrying out file transfers; and 3. The client disconnects (although disconnecting informally - that is, without telling the server you're about to disconnect - can be done safely).
To establish a connection, the client attempts to connect to TCP port 21 at the server's IP address. The client then authenticates through the user name command ("user <name>") and password command ("pass <pwd>"). Here's what an exchange between client and server looks like for anonymous access:
220 ftp.silcom.comready. Unauthorized access prohibited.
user anonymous
331 Guest login ok, send your complete e-mail address as password.
pass gearhead@gibbs.com
230 Guest login ok, access restrictions apply.
Note that many FTP servers will check to see if the given e-mail account (or sometimes just the domain) exists and will deny access if it doesn't.
As with most Internet protocols, a status code is added to text status message. This makes it possible for applications that might not understand the text reply to understand the responses.
For access through a named account, the process looks more-or-less the same:
220 ftp.somehost.com ready. Unauthorized access prohibited.
user gearhead
331 Password required for gearhead.
pass verysecret
230 User gearhead logged in.
So let's say we want to list the default directory on logon. We have to first set the format for data transfers to the client. This is done with the "type <type>" command. The argument <type> can be A for ASCII (used for test file transfers), E for EBCDIC (for all you old IBMers), or I for image (as in no translation). We can now use the "pwd" command to print the name of the working directory. Thus:
TYPE I
200 Type set to I.
pwd
257 "/" is current directory.
So we've been connected to the FTP server, we've been authenticated, and we know what directory we're in. Now it gets interesting, but you'll have to wait 'til next week as we've run out of space.
Transfer your thoughts to gearhead@gibbs.com.
RELATED LINKS
Comments and suggestions to gh@gibbs.com.
Gibbs Forum
The place to discuss Gibbs's columns.
Check out this week's edition of
Backspin for more musings from Gibbs.
Part 2: The connection to the
server is made
Network World, 7/30/01.
Part 3: Connection
modes
Network World, 8/6/01.
Part 4: Let the transfers begin
Network World, 8/13/01.
Part 5: FTP server security
Network World, 8/20/01.
Part 6: SITE and SYST
Network World, 8/27/01.

