Sie sind auf Seite 1von 19
T e a c h T e a c h Yourself Yourself Prese nted by:

Teach

Teach

Yourself

Yourself

Presented by:

Dave Taylor

T e a c h Yourself Yourself Prese nted by: Dave Taylor Unix 24 in Hours

Unix

24 in Hours
24
in
Hours

FOURTH EDITION

800 East 96th Street, Indianapolis, Indiana 46240 USA

Sams Teach Yourself Unix in 24 Hours, Fourth Edition

Copyright © 2006 by Sams Publishing

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.

International Standard Book Number: 0-672-32814-3

Library of Congress Catalog Card Number: 2005902143

Printed in the United States of America

First Printing: August 2005

08

07

06

05

4

3

2

1

Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

Warning and Disclaimer

Every effort has been made to make this book as complete and as accu- rate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book

Bulk Sales

Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact

U.S. Corporate and Government Sales

1-800-382-3419

corpsales@pearsontechgroup.com

For sales outside of the U.S., please contact

International Sales international@pearsontechgroup.com

Acquisitions Editor

Jenny Watson

Development Editor

Scott Meyers

Managing Editor

Charlotte Clapp

Senior Project Editor Matthew Purcell

Indexer

Erika Millen

Proofreader

Leslie Joseph

Technical Editor

Timothy Boronczyk

Team Coordinator

Vanessa Evans

Book Designer

Gary Adair

Page Layout

Julie Parks

HOUR 21

Using telnet, SSH, and ftp

In the preceding hour, you learned how to use electronic mail to interact with other users both on your system and elsewhere on the Internet. In this hour, you see how to use Unix tools to connect to remote systems and transfer files and programs back and forth at will.

Goals for This Hour

In this hour, you will learn about

.

Connecting to remote Internet sites

.

Securing connections with SSH

.

Using FTP to transfer files

.

Working with Anonymous FTP Archives

This hour is intended to offer a quick overview of how to connect to other Unix systems on the Internet, both to transfer files and to interact directly.

Stepping Beyond Your Own System

You can do lots of things on a local Unix system, but if you’re lucky, your system is hooked up to the rest of the Internet world. Unix offers some powerful tools to let you exploit your network connectivity.

Task 21.1: Connecting to Remote Internet Sites

The really fun part of Unix, and one reason that it continues to grow dramatically in pop- ularity, is that it’s the most connected operating system in the world. The variety of servic- es available for users of a networked Unix machine is staggering.

The Internet can help you with three main tasks: using remote systems, sending mail to remote users, and sending files back and forth with remote file systems.

418

HOUR 21: Using telnet, SSH, and ftp

If you know that the remote site is a Unix system, the easiest way to log in to that site is to use the rlogin command, which has the awkward notation of rlogin host -l account. If you aren’t sure about the remote operating system, use telnet, which is the universal program for connecting to remote computer systems. Unlike any of the other programs you’ve learned so far, telnet actually works either as a simple program you can invoke from the command line or as a sophisti- cated environment for connecting to various systems.

1. First, I’ll use rlogin to connect to a remote system and see whether I have a file there:

$ rlogin intuitive.com Password:_

By default, rlogin assumes that your account on the remote system has the same name as your account on your home system. If you forget to use the -l account option, press Return here, and it prompts for an account name:

$ rlogin intuitive.com Password:

Login incorrect

login: taylor

Password:_

After I enter my password, I’m logged in to the remote system:

Last login: Mon May 13 15:27:24 from 204.247.39.239

IntuitiveIntuitive Systems, Inc.

It’s Wed May 18 10:33:15 PDT 2005$

Using ls tells me what I want to know:

intuitiveintsys $ ls

Global.Software

News/

history.usenet.Z

Interactive.Unix Src/

login

Mail/

bin/

testme

intuitiveintsys $

2. The rlogin command offers a shorthand notation for logging out of the remote system; instead of using logout, you can simply enter ~. to do the job. To stop the rlogin session, use ~^z. No other tilde commands are available in

rlogin.

I choose to log out the normal way:

intuitiveintsys $ exit Connection closed

$

Stepping Beyond Your Own System

Now I’m back on the original computer system.

419

3. The alternative way to connect to a remote computer is to use telnet. The easiest way to use this command is the same way you use rlogin. At the com- mand prompt, specify the name of the system to which you want to connect:

$ telnet intuitiveintuitive.com Trying Connected to intuitiveintuitive.com. Escape character is ‘^]’.

FreeBSD UNIX (intuitive)

login: _

Notice that this way is much more like having a terminal connected to this system. I can log in, enter my password, and then have a new login session on the remote system as if I were sitting in that computer room working away.

4. Instead, though, I’m going to use the ^] control character to switch back into the telnet program itself:

FreeBSD UNIX (intuitiveintuitive) login: ^] telnet > _

Now I enter help to see what the options are:

telnet> help Commands may be abbreviated. Commands are:

close

close current connection

logout

forcibly logout remote user and close the connection

display

display operating parameters

mode

try to enter line or character mode (‘mode ?’ for more)

telnet

connect to a site

open

connect to a site

quit

exit telnet

send

transmit special characters (‘send ?’ for more)

set

set operating parameters (‘set ?’ for more)

unset

unset operating parameters (‘unset ?’ for more)

status

print status information

toggle

toggle operating parameters (‘toggle ?’ for more)

slc

change state of special characters (‘slc ?’ for more)

auth

turn on (off) authentication (‘auth ?’ for more)

encrypt

turn on (off) encryption (‘encrypt ?’ for more)

z

suspend telnet

!

invoke a subshell

environ

change environment variables (‘environ ?’ for more)

?

print help information

telnet> _

420

HOUR 21: Using telnet, SSH, and ftp

There are lots of possible commands. I choose to return to my connection to my Intuitive server, however; I press Return, and I’m back at the login prompt. If I don’t enter anything quickly enough, the remote system automatically drops the connection:

login: Login timed out after 60 seconds Connection closed by foreign host.

$

To log out of the remote system, the best strategy is simply to exit the telnet session, which will drop the line automatically. If that doesn’t work, the ^] sequence followed by either quit or close will do the trick.

5. To start out directly in the telnet command mode, enter the command with- out specifying a remote host:

$ telnet

telnet> _

From here, connecting to the remote host is also quite simple:

telnet> open intuitive.com Trying Connected to intuitive.com. Escape character is ‘^]’.

SunOS UNIX (intuitive)

login: _

Again, I use ^] and close to close the connection.

Both the rlogin and the telnet commands are useful in different situations, but I find myself using the rlogin command more often because it sends much of the current environment along to the remote system. So if I have my system set for a specific type of terminal (that is, the TERM variable is set to a specific value), that value is automatically copied into the new environment of the remote system, which saves lots of hassle.

Task 21.2: Telnet from Windows and Macs

Another way that you can use telnet is to use it as a mechanism for connecting to the Unix machine you’re working with. That’s how I connect to my systems now: It’s been rather a long time since I had an actual Unix terminal or computer on my desktop.

Stepping Beyond Your Own System

421

A variety of different telnet programs are available for both the Mac and PC and

both the latest version of Mac OS X and Windows include built-in telnet clients too

(on the Mac, it’s accessible from Terminal, and on the PC, open an MSDOS window).

If you need a separate program, one of the best places to look for free telnet client

programs is Download.com: Just search for ‘telnet’ when you get there.

1.

Although I usually spend most of my time on the Macintosh platform, I do occasionally delve into the arcane Windows environment. When I’m on a Windows system and want to use a simple telnet program to connect, it turns out that there’s already one included with Windows.

A

secret: The easiest way to launch your telnet program is to simply use your

Web browser to find it. That’s right, just enter the URL telnet: and it will find

and launch the program you have on your system.

2.

If

that doesn’t work, you can go to Start, Find, Files or Folders and search for

“telnet” on your Windows system. It will show a number of results, and the one you want is the telnet.exe application. Double-click it, and you’ll see a blank white window. Choose Connect, Remote System and it will look like Figure 21.1.

Connect, Remote System and it will look like Figure 21.1. FIGURE 21.1 Windows ‘tel- net’ when

FIGURE 21.1

Windows ‘tel- net’ when first launched.

As you can see, it’s fairly bare bones, but enter the name of the system to which you want to connect, and it’ll open a window running as a vt100 termi- nal. (Remember you might have to change the TERM settings in your shell to match).

422 HOUR 21: Using telnet, SSH, and ftp Some versions of telnet (such as on
422
HOUR 21: Using telnet, SSH, and ftp
Some versions of telnet (such as on Win 98, but not XP) may not have local
echo enabled. Another option that’s included with Windows XP is
HyperTerminal, as shown in Figure 21.2.
FIGURE 21.2
Windows XP
includes the
more sophisti-
cated
HyperTerminal.

Launch HyperTerminal by going to Start -> Applications -> Accessories -> Connectivity.

3. I’ll switch over to my Macintosh for a moment to show you that there are also easy (free) telnet clients for the Macintosh platform.

On the Macintosh, however, no graphical interface based telnet clients are included with the operating system (though there is a free telnet client includ- ed with the Unix side of Mac OS X). Instead, I popped over to http://www.download.com/ and found 10 different telnet clients listed!

Of those, the two most popular are MacSSH and ProTerm.

My personal favorite, however, is the telnet program that’s built into the Mac OS X operating system.

4. If you’ve downloaded any of these, you’re going to start them up with a dou- ble-click and see something similar to Figure 21.3, which shows the built-in telnet application included with Mac OS X in a Terminal window.

Stepping Beyond Your Own System

Stepping Beyond Your Own System 423 FIGURE 21.3 Telnet as includ- ed with Mac OS X,

423

FIGURE 21.3

Telnet as includ- ed with Mac OS X, in a Terminal window.

There are many different settings for a telnet session, but I think that’s a good thing. You can specify the default window size, typeface to use, and even the foreground and background colors, all in one place. Then, you can save it as a shortcut, and you’re ready to go!

Task 21.3: Secure Connections with SSH

Telnet and its ilk are tremendously useful programs, but they have inherent security problems, important problems, not the least of which is that the information between the client and the server is “in the clear.” That is, if you could somehow interpose a network packet sniffer that could filter out just the telnet traffic, you could read the account/password pair and everything that’s displayed on the remote users display.

Although a number of possible solutions exist for this problem, Tatu Ylönen at Helsinki University of Technology in Finland came up with the best one: SSH. SSH stands for Secure Shell, a point-to-point encrypted telnet protocol. If your server sup- ports SSH, you should unquestionably use it. There are no downsides that I’ve found, and the additional security is a definite boon.

On the PC side, the SSH client of choice is unquestionably AbsoluteTelnet, which includes SSH support and can be found at http://www.celestialsoftware.net/ It’ll cost you $30 USD. There are a bunch of low-cost alternatives, actually, including PuTTY. Go to download.com to see for yourself.

For Macintosh users, an SSH client is included with Mac OS X too, so you need mere- ly open up the Terminal (it’s in Applications -> Utilities) and type ssh to get started. If you have an earlier version of the Mac operating system, the best option is

424

HOUR 21: Using telnet, SSH, and ftp

MacSSH, a free application that you can find online at http://pro.wanadoo.fr/ chombier/. Note that it only runs on MacOS9, not Mac OS X, but since there’s a built-in SSH client within Mac OS X, that’s not a big worry.

If you’re already on a Unix system, odds are extremely good that you already have

an SSH client. Just type ssh and see what happens. If it’s not included, ask your sysadmin, or use Google to search for “ssh client” and the name of your flavor of Unix.

One important warning: Two incompatible versions of the SSH protocol, SSH 1 and SSH 2, can be installed on servers. If you try to connect to a secure server and it fails, try the other protocol (all SSH clients give you a choice). Start with the more modern SSH2 protocol.

1. To connect to a secure server with a command-line SSH application is a breeze: just type ssh at the command line:

$ ssh taylor@intuitive.com The authenticity of host ‘intuitive.com (128.121.96.234)’ can’t be established. RSA1 key fingerprint is e0:41:23:6a:1d:d5:d0:c6:10:8c:fd:66:ac:9c:14:c0. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘intuitive.com,128.121.96.234’ (RSA1) to the list of known hosts. taylor@intuitive.com’s password:

2. After you’re connected to an SSH server, the client program really works almost 100% identically to a telnet client, without any apparent performance issues or other downsides.

The Internet has grown and become a tremendously popular place, both for nice folk offering lots of cool and compelling information and for bad people trying nefarious schemes to break in and steal information. I don’t think of myself as overly paranoid about things, but I like the security that I get from using SSH instead of regular telnet, and on my own servers, I only run SSH software: Regular telnet clients cannot connect at all.

My recommendation: If you have a server that supports SSH, it’s definitely in your best interest to switch to an SSH client and use that instead of raw telnet.

Task 21.4: Copying Files with FTP

The main program used to copy files on the Internet is ftp, which is named after the protocol it implements, the file transfer protocol. Like much of Unix, ftp can take

a while to master, particularly because no effort has been made to make it at all

user-friendly. Nonetheless, it functions very similarly to the telnet command; either

Stepping Beyond Your Own System

425

you enter ftp to start the program and then specify the system with which you’d like to connect, or you specify the name of the system on the command line. Either way, you are prompted for an account and password; then you are dropped into ftp with the connection open and waiting.

The more sophisticated SSH clients also offer a secure file transfer protocol called sftp that’s actually running on top of SSH. Given the choice, use sftp rather than ftp because, again, your password and the files themselves are all transmitted encrypted rather than in the clear.

By the

Way

Many sites have anonymous ftp capabilities. Systems allowing this connection indi- cate that you don’t need your own computer account on that machine to be able to connect and copy files from their archives. To use these systems, enter ftp as the account name, and then enter your own email address as the password (for exam- ple, I’d enter ftp as the account and then taylor@intuitive.com as my password). The most important commands available in ftp are summarized in Table 21.1. The most important one to remember is bye, which you use when you’re done.

TABLE 21.1

Valuable ftp Commands

Command

Meaning

!cmd

Run cmd in a subshell on the local system.

ascii

Set ftp to transfer a text (ASCII) file.

binary

Set ftp to transfer a binary file, probably a program or data- base of information.

bye

Quit the ftp program. Note that quit is an alias for bye.

cd dir

Change the remote directory to dir.

close

Close the current connection.

dir

Print a listing of files in the current remote directory.

get

Transfer a file from the remote system to your local system.

help

Access the application’s help system.

lcd dir

Change the current directory on the local system to dir or to your home directory if no argument is given.

ls

List the files in the current remote directory (try this: The output is usually different than the dir command produces).

mget

Multiple get—get files with a wildcard matching capability (example: mget *.c).

mput

Multiple put—put files with a wildcard matching capability (example: mput *.html).

426

HOUR 21: Using telnet, SSH, and ftp

TABLE 21.1

Continued

Command

Meaning

open

Open a connection to the specified remote machine.

prompt

Control whether or not to ask for confirmation of each file trans- ferred if using mget or mput.

put

Put a file onto the remote system from the local system (exam-

ple: put index.html).

pwd

Show the present working directory on the remote system.

1. To begin, I want to pick up a file from intuitive that I saw earlier when I used rlogin to look at the remote system. To start ftp, I use the short nota- tion of specifying the host at the command line:

$ ftp intuitive.com

Connected to intuitive.com.

210 intuitive FTP server (Version 2.1 Fri Apr 9 13:43 PDT 2003) ready.

Name (intuitive.com:taylor): _

By default, ftp assumes that I want to use the same account name, which in this case I do, so I press Return and then enter my password:

Name (intuitive.com:taylor):

331 Password required for taylor.

Password:

230 User taylor logged in.

ftp> _

2. Now I’m at the ftp program prompt, and any of the commands shown in Table 21.1 will work here. To start, I use dir and ls to list my files in different formats:

ftp> dir

200

PORT command successful.

150

Opening ASCII mode data connection for /bin/ls.

total 140

-rwxr-xr-x

1 taylor

users0

4941 Oct

4

1991 .Pnews.header

-rw-r--r--

1 taylor

users0

2103 Sep 30 19:17 .article

-rw-r--r--

1 taylor

users0

752 Apr 17

1998 .cshrc

drwx------

2 taylor

daemon

4096 Dec

6 14:25 .elm

-rw-r--r--

1 taylor

users0

28 Nov

5 09:50 .forward

-rw-r--r--

1 taylor

users0

1237 Dec 13 09:40 .login

-rw-r--r--

1 taylor

users0

6 Aug

6

1991 .logout

-rw-r--r--

1 taylor

users0

538 Dec

-rw-r--r--

1 taylor

users0

6 14:32 .newsrc 1992 .plan

1610 Feb 17

-rw-r--r--

1 taylor

users0

0 Aug

6 1991 .pnewsexpert

-rw-r--r--

1 taylor

users0

45 Feb

2

1993 .rnlast

-rw-r--r--

1 taylor

users0

6 Feb

8

1993 .rnlock

-rw-r--r--

1 taylor

users0

16767 Jan 27

1993 .rnsoft

-rw-r--r--

1 taylor

users0

114 Apr

6

1998 .sig

Stepping Beyond Your Own System

427

drwxr-xr-x

4 taylor

users0

4096 Nov 13 11:09 .tin

-rw-r--r--

1 taylor

users0

1861 Jun 2 1997 Global.Software

-rw-------

1 taylor

users0

21194 Oct 1 1995 Interactive.Unix

drwx------

4 taylor

users0

4096 Nov 13 11:09 Mail

drwxr-xr-x

2 taylor

users0

4096 Nov 13 11:09 News

drwxr-xr-x

2 taylor

users0

4096 Nov 13 11:09 Src

drwxr-xr-x

2 taylor

users0

4096 Nov 13 11:09 bin

-rw-r--r--

1 taylor

users0

12445 Sep 17 14:56 history.usenet.Z

-rw-r--r--

1 taylor

users0

1237 Oct 18 20:55 login

-rw-r--r--

1 taylor

users0

174 Nov 20 19:21 testme

216 Transfer complete.

1792 bytes received in 3.1 seconds (0.56 Kbytes/s) ftp> ls

200

PORT command successful.

150

Opening ASCII mode data connection for file list.

Mail

News

bin

Global.Software

history.usenet.Z

Src

Interactive.Unix

testme

login

216

Transfer complete.

269

bytes received in 0.02 seconds (13 Kbytes/s)

ftp>

As you can see, ftp can be long-winded, particularly with the DIR output format.

One trick for using the ls command within ftp is that if you specify a set of com- mand flags as a second word, it works fine. Specify a third argument, however, and it saves the output of the command into a local file by that name; so ls -l -C would create a file called -C on your system with the output of the ls -l command.

By the

Way

Because you can supply some flags to the ls command, I always use -aCF to force the output to list dot files in multiple columns and show directories, which makes the output more readable:

ftp> ls -aCF

200

PORT command successful.

150

Opening ASCII mode data connection for /bin/ls.

.Pnews.header*

.newsrc

Interactive.Unix

.accinfo*

.oldnewsrc

Mail/

.article

.plan

News/

.cshrc

.pnewsexpert

Src/

.delgroups

.rnlast

bin/

.elm/

.rnlock

history.usenet.Z

.forward

.rnsoft

login

.ircmotd

.sig

testme

.login

.tin/

428

HOUR 21: Using telnet, SSH, and ftp

.logout

Global.Software

216 Transfer complete.

remote: -CF

287

bytes received in 0.05 seconds (5.6 Kbytes/s)

ftp>

3. To transfer the file login from the remote system, I can use the get command:

ftp> get

(remote-file) login

(local-file) login.intuitive

200

PORT command successful.

150

Opening ASCII mode data connection for login (1237 bytes).

216

Transfer complete.

local: login.intuitive remote: login

1281

bytes received in 0.21 seconds (5.7 Kbytes/s)

ftp>

This can get a bit tricky. I’ve just copied the login file from intuitive (where I FTP’d) to the local Unix system where I’m running the ftp command itself. On the local system, I gave the file the new name of login.intuitive.

Also, there’s a bit of difference between ascii and binary file transfers: the former converts any carriage returns or control characters in text files to work on the remote system, while the latter copies the data, bit for bit, without any alterations at all. Copying images or programs in ascii is disasterous, and copying plain text files, shell scripts, Perl scripts, etc., as binary can be prob- lematic too.

4. Alternatively, I could use mget and specify a wildcard pattern similar to one I’d give the shell:

ftp> mget log* mget login? y

200

PORT command successful.

150

Opening ASCII mode data connection for login (1237 bytes).

216

Transfer complete.

local: login remote: login

1281

bytes received in 0.03 seconds (42 Kbytes/s)

ftp>

There was only one match, so the transfer was easy. Entering anything other than y at the mget login? prompt would have resulted in the file not being transferred. The mget and mput commands are particularly useful if you want to transfer many files at once, so mget *.? would get *.c, *.h, and any other source files that have a single-letter suffix to their filenames, for example.

That job was easily accomplished. Now I will look on another system in the anonymous FTP directory to see what’s available.

Stepping Beyond Your Own System

429

5. To disconnect, I enter close so that I don’t leave the ftp program:

ftp> close

211 Goodbye

ftp>

Leave ftp running, we’ll be back in just a moment.

Though the interface is relatively crude, FTP, and its secure cousin sftp, is an easy and efficient method of transferring files quickly between two systems, regardless of operating system. It’s worth learning, but, worst case, you can always get a nice graphical front-end, either within X11, Windows, or the Mac environment.

Task 21.5: Exploring Anonymous FTP Archives

FTP is a simple method of transferring files, but it turns out that you can work with many FTP archives even if you don’t have an actual login account on the system. Known as anonymous ftp archives, these sites are typically massive archives of data and applications and a valuable alternative to the more common Web-based archival sites. Let’s have a look!

1. There are hundreds of information servers on the Internet, offering an astounding variety of information, from weather service maps to the full text of the Bible and Alice in Wonderland to the source listings of thousands of programs.

In this example, I want to look at the anonymous FTP archive at Washington University in St. Louis, Missouri. The host is called wuarchive.wustl.edu and since I never quit ftp earlier, it’s easy to just open up a new archive site:

ftp> open wuarchive.wustl.edu

Connected to wuarchive.wustl.edu.

220 (vsFTPd 2.0.1)

Name (wuarchive.wustl.edu:taylor): ftp

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX. Using binary mode to transfer files. ftp>

Now I can use ls -CF to look around:

ftp> ls -CF

229

Entering Extended Passive Mode (|||48527|)

150

Here comes the directory listing.

drwxr-xr-x

2 0

0

4096 Nov 05 2004 ECgift/

d--x--x--x

2 0

0

4096 Oct 14

2004 bin/

d--x--x--x

2 0

0

4096 Oct 14

2004 etc/

d--x--x--x

2 0

0

4096 Oct 14

2004 lib/

430

HOUR 21: Using telnet, SSH, and ftp

lrwxrwxrwx

1

0

0

3 Oct 20

2004 mirrors -> pub

drwxr-xr-x

11 1941

20127

4096 Apr 28 22:17 pub/

-rw-r--r--

1

0

0

234 Oct 15 2004 welcome.msg

226

Directory send OK.

ftp>

It looks as though there might be something of interest in the pub directory (a directory by this name usually contains public information), but before we check it out, let’s go ahead and read the welcome message.

2. To read a text file, get it, but copy it to /dev/tty:

ftp> get welcome.msg /dev/tty

local: /dev/tty remote: welcome.msg

229

Entering Extended Passive Mode (|||33182|)

150

Opening BINARY mode data connection for welcome.msg (234 bytes).

Welcome to wuarchive.wustl.edu !

The local time is: %T

If have any unusual problems, please report them via e-mail to <root@%L>.

If you have any ideas for content that you would like to be mirrored here please contact <root@%L>.

226

File send OK.

234

bytes received in 00:00 (17.70 KB/s)

ftp>

Ah, not too exciting after all. Let’s jump into pub and see what’s there instead.

3. I use cd to change to that directory, then dir to see what’s available there:

ftp> cd pub

250 Directory successfully changed.

ftp> dir

229

Entering Extended Passive Mode (|||60406|)

150

Here comes the directory listing.

drwxr-xr-x

15 21

50

4096 Jun 25 2004 FreeBSD

drwxr-xr-x

14 99

0

4096 May 04 12:48 OpenBSD

drwxr-xr-x

21 0

0

4096 Nov 04 2004 aminet

lrwxrwxrwx

1

0

0

38 Apr 11 17:12 centos40 ->

linux/distributions/centos/4.0/os/i386

drwxr-xr-x

5 0

0

4096 Oct 20 2004 cygwin

drwxr-xr-x 254 1898

20127

8192 Jan 06 03:11 gnu

drwxr-xr-x

3 0

0

4096 Oct 14

2004 linux

drwxr-xr-x

3 0

0

4096 Apr 28 22:21 mozilla

drwxr-xr-x

5 0

0

4096 Oct 28

2004 ssh

drwxr-xr-x

6 0

0

4096 Oct 20 2004 wu-ftpd

226

Directory send OK.

ftp>

There’s quite a lot on the archive server, as you can see. You could explore fur- ther with cd and dir, until you found something of interest, but let’s move along to another archive.

Stepping Beyond Your Own System

431

4. It’s time to split and check another FTP archive, this time one at Apple

Computer (ftp.apple.com):

ftp> close

211 Goodbye.

ftp> open ftp.apple.com Trying 17.254.16.10

Connected to ftp.apple.com.

220 ProFTPD 1.2.9 Server (Apple Anonymous FTP Server) [ftp01.apple.com]

Name (ftp.apple.com:taylor): ftp

331 Anonymous login ok, send your complete email address as your password.

Password:

230 Anonymous access granted, restrictions apply.

Remote system type is UNIX. Using binary mode to transfer files.ftp>

Again, ls -CF shows what files are available:

ftp> ls -CF

200

PORT command successful

150

Opening ASCII mode data connection for file list

Apple_Support_Area/

emagic/

research/

developer/

filemaker/

226

Transfer complete.

ftp>

I’ve been to this site before, and I know that a few directories down there are a lot of useful applications to help make a Macintosh friendlier for people with disabilities. Let’s have a look by using the cd command to move:

ftp> cd /research/neural/larryy/polyworld

250 CWD command successful.

You could use the DIR command to see what’s in this directory, but I already know that there’s a file called README that I want to save to my own system. I’ll do a wildcard listing instead:

ftp> dir R*

200

PORT command successful

150

Opening ASCII mode data connection for file list

-rwxrwxrwx

1 ftpprod ftpprod

12641 Jan 19

1996 README

226

Transfer complete.

ftp>

5. To copy the file is simple, just use the get command:

ftp> get README local: README remote: README

200

PORT command successful

150

Opening BINARY mode data connection for README (12641 bytes)

100%

|**********************************************************************|

12641 35.75 KB/s

226 Transfer complete.

00:00 ETA

432

HOUR 21: Using telnet, SSH, and ftp

12641 bytes received in 00:00 (31.59 KB/s)

ftp>

Before I’m done, I’ll just quickly check to see that I’m in a known local directo- ry (to avoid the ‘where did it copy that darn file?’ syndrome):

ftp> !pwd /Users/taylor/Desktop ftp>

Remember, any command prefaced with ! is given to the command shell, so !pwd shows the present working directory within which the ftp program is running.

Perfect. I quit the application and double check that the file really is in my Desktop folder, and:

ftp> quit

221 Goodbye.

$ cd /Users/taylor/Desktop

$ ls -l README

-rw-r--r-- 1 taylor

staff

12641 18 Jan

1996 README

The FTP system is a terrific way to obtain information from the Internet. Thousands of systems offer various services via anonymous FTP too: Table 21.2 lists a few of the most interesting ones.

TABLE 21.2

Some Interesting ftp Archives

Site

Institution and Available Information

ftp.sfu.ca

San Francisco University. Files: MS-DOS, Mac.

ftp.apple.com

Apple Computer. Files: Apple (Mac, II, IIgs) product information, software, developer support.

ftp.csc.liv.ac.uk

Liverpool University Computer Science Department. Files: Ports to HP-UX machines (especially Series 700), including X11R4 clients, GNU, recreational soft- ware, text editors, system administrator tools.

gatekeeper.dec.com

Compaq Corporate Research (formerly Digital Equipment Corporation), Palo Alto, California. Files:

X11, recipes, cron, map, Modula-3.

info.umd.edu

University of Maryland. Files: government-related, books, economics, MS-DOS, Novell, Mac.

ftp.sri.com

SRI International. Files: Improving the security of your Unix system.

ftp.cc.columbia.edu

Columbia University. Files: kermit.

Workshop

433

Summary

There’s no question that the interface to ftp is awkward. The good news is that most people have a Windows or Macintosh system as their actual desktop, and there are a ton of great FTP clients for both systems. For the PC I really like FTP Explorer by Alan Chavis, at www.ftpx.com. On the Macintosh, it’s hard to beat the well- designed NetFinder, written by Peter Li and Vincent Tan, which you can find at

members.ozemail.com.au/~pli/netfinder.

Workshop

The Workshop summarizes the key terms you learned and poses some questions about the topics presented in this hour. It also provides you with a preview of what you will learn in the next hour.

Key Terms

anonymous FTP

you to have an account on the system.

A system set up to respond to ftp queries that does not require

search string

The pattern specified in a search.

Exercises

1. Use telnet and rlogin to try to log in to one of the FTP server sites shown in Table 21.2. You won’t have an account, so drop the connection once you see a login: prompt.

2. Use ftp to connect to ftp.sri.com and see what files the research institute has made available to anonymous FTP users. Copy one onto your system, and read through it to see what you think about the organization itself.

3. What key ftp command must you use before you download a compiled pro- gram or photograph? How about a shell script?

Preview of the Next Hour

This chapter offered you a tour of the basic tools of the Internet. In the next hour, you will learn how to search on your Unix system—and elsewhere on the Internet— for specific files, and how to work with them.