-->
Previous Table of Contents Next


Chapter 15
FTP and Telnet

by Tim Parker

In This Chapter
•   FTP
•   Setting up FTP server service
•   Using FTP
•   Trivial file transfer protocol (TFTP)
•   Using Telnet

Two of the most useful tools for communicating with other Linux and UNIX systems (or any operating system, for that matter) are FTP (for transferring files) and Telnet (for logging in to other systems). In this chapter we’ll look at how you can use both tools, as well as mention TFTP, which is a simplified version of FTP.

FTP

There are two different ways to use FTP and TFTP: through a command line or through a graphical interface. Most Linux systems are restricted to character-based commands unless you find a shareware or commercial GUI product. GUI-based FTP clients are much more common on Windows machines. Both character and GUI versions accomplish exactly the same task (the transfer of files from one machine to another) but do it through a different user interface. We’ll concentrate on the character-based versions here because that’s what most Linux systems provide.

When it comes to what the function of FTP is and what FTP does, the name essentially says it all: File Transfer Protocol. FTP was developed specifically to provide a method of transferring files from one machine to another without needing complex communications protocols like XMODEM, YMODEM, ZMODEM, or Kermit, as well as removing the need to log in to the remote machine fully. FTP provides a quick method of logging into the remote machine, moving about the file system (subject to permissions, of course), and transferring files either to or from the remote system quickly.

To use FTP to transfer files, the machine you are running (the client) must have FTP client software. Linux and UNIX machines almost always have the FTP client software included as part of their basic distribution system. The other end of the connection—the machine you want to connect to—is called the server, and it must be running a program that accepts incoming FTP requests. This is called the FTP server and usually must be running all the time for FTP connections to work.

Multitasking operating systems like Linux usually have the FTP server program included as part of the basic distribution. In most cases, the server is called “ftpd,” which stands for FTP daemon. (A daemon is a program that operates in the background while a machine is running.) The ftpd daemon is almost always loaded automatically as part of the Linux boot process, unless the system administrator explicitly removes it.

If you are connecting to a PC (running OS/2, Windows, Windows 95, NetWare, or a similar operating system) or a Macintosh server, chances are the server will not have FTP server software running by default. When these operating systems are installed, they lack most of the TCP/IP services. The system administrator must activate them explicitly. Without the server software running on a PC, you can’t connect to the server with your FTP client.

Most TCP/IP packages for PCs and Macintoshes include a server program for FTP that enables other users to connect to that machine. Indeed, most TCP/IP packages have both the FTP client and FTP server software as part of the distribution, enabling you to set your machine up as both a client and a server to others (assuming you want to allow others access to your file system).

Setting Up FTP Server Service

Before we look at how to connect and transfer files from another machine (the server), we should mention how you can set up your machine as an FTP server. You may have to do this on the remote machine, too. Each machine that is to accept transfer requests must have the FTP server software active. This is pretty easy to do, as you will see in a moment. You can also set up your existing machine as an FTP server, allowing other machines on the network to connect into your system and transfer files.

All the clients and server software programs you might need are included as part of the Linux distribution (although it must be installed, of course). It doesn’t matter whether you are setting up access-controlled or anonymous FTP services because the basic steps you follow to install and configure the FTP daemon are the same.

The configuration process starts with choosing an FTP site name. You don’t really need a site name, although it can make it easier for remote users to find your system, especially if they are using an anonymous login. FTP site names are usually of the general format


ftp.domain_name.domain_type

where domain_name is the domain name (or an alias) of the FTP server’s domain, and domain_type is the usual DNS extension. For example, if you have an FTP site named


ftp.tpci.com

it is clear that this is the FTP server for anyone accessing the tpci.com domain.

The FTP daemon, called ftpd, must be started. Usually, the inetd process starts the FTP daemon by watching the TCP command port (channel 21) for an arriving request for a connection. Then it starts ftpd to service that request.


Note:  
Make sure that ftpd can be started when needed by inetd by checking the inetdconfiguration file (usually /etc/inetd.config) for a line that looks like this:

ftp  stream  tcp  nowait  root  /etc/ftpd ftpd

If this line doesn’t exist, add it. With most Linux and UNIX systems, this line is already in the inetd configuration file, although it may be commented out—in which case you should remove the comment symbol.


The ftp entry in the inetd configuration file tells inetd that FTP is to use TCP and that it should spawn ftpd every time a new connection is made to the ftp port. The ftpddaemon can be started with the -l option attached, which enables logging. You can ignore this option if you want as long files get quite large, quickly.


Previous Table of Contents Next