USING TELNET

Telnet as a login tool

Telnet is a protocol that is usually used by people to log in to computer systems that have a command-line interface. A command-line interface presents you with a prompt, after which you are expected to type a command. The computer executes the command, and the prompt reappears, indicating that the computer is ready to execute the next command.

To use telnet in the usual way, you first need to have an account on a suitable computer system. Luckily for you, you already have such an account on the Math/CS computers (I will give you the relevant information in class on Wednesday). In the following exercise, you will use the telnet client that comes with Windows to connect to prism.mathcs.carleton.edu.

Note that throughout the notes below, when it says "enter this" or "type that", you should press the Enter key after entering this or typing that. (Go ahead and say "well, duh!", but even in this age of widespread computer use, I have seen many people waiting patiently for the computer to respond while the computer is waiting patiently for an Enter.)

Telnet Exercise the First

In which the intrepid CS107 student ("ICS") logs in to prism, changes his or her password, and learns a few elementary UNIX commands.

Step 1: The ICS induces Windows to launch the telnet client.

In the CMC 301 or 306, double-click on the "ssh-telnet.exe" icon. Enter "prism.mathcs.carleton.edu" in the "Host Name" box. Click on Open.

(Alternatively, if you're at home or on some other Windows system, go to the Start menu, choose Run, enter "telnet prism.mathcs.carleton.edu", and click OK.)

Step 2: The ICS logs in to prism, the computer system of many colours. (most notably, black and white).

Type your user name in response to the "login:" prompt and then type your Math/CS password. You should see a message from Mike Tie followed by a prompt (probably "prism>"). At this prompt, you can type UNIX commands, of which you will learn several during this term.

Step 3: The ICS changes his or her weird initial password to a password of his or her own devising.

Type "yppasswd". You will be asked for your old password. Type it. Then you will be asked to type your new password twice. Do so. From now on when you log in, you will use the new password.

Step 4: The ICS uses "ls" (the command whose name was tragically stripped of its "i" and "t") to list the contents of the ICS's account.

Type "ls". You should see a brief listing of the contents of your account. Type "ls -l" (that's a hyphen followed by an ell, not a one). You will see a detailed listing of the contents of your account. Note that a "d" in the leftmost column indicates a "directory," which is another name for a folder. Try to figure out the other information the detailed listing provides.

Step 5: The ICS discovers the time, and ponders the quickness of its passage.

Type "date". Go ahead and type it again. Watch those seconds pass!

Step 6: The ICS discovers that previous commands can be executed again with dispatch.

Press the up-arrow key. Press it again a couple times. Press the down-arrow key until you arrive at the "date" command. Hit Enter.

Step 7: The ICS has had enough, and logs out.

Type "logout". Close the telnet window.

Telnet used to experiment with other protocols

Telnet can be used to communicate directly with servers other than telnet servers. By specifying a port number, you can communicate with the server without using a specialized client (e.g. a web browser, an ftp program, etc.) as an intermediary.

This exercise will show you how to communicate directly with the web server running on prism.

Telnet Exercise the Second

In which the intrepid CS107 student logs back in to prism, and converses with an HTTP server in its native tongue.

Step 1: The ICS logs in to prism.

As above. Don't forget to use your new password.

Step 2: The ICS offers to converse with the HTTP server on another machine.

In response to prism's prompt, type "telnet www.mathcs.carleton.edu 80", which instructs the UNIX telnet command to open a TCP connection to port 80 on the computer named www.mathcs.carleton.edu (which is a machine distinct from, but about three feet below, prism--both machines are in the locked portion of CMC 307).

Step 3: The ICS requests a file from the HTTP server on www.mathcs.carleton.edu.

You should see something like this:


	Trying 137.22.4.90...
	Escape character is '^]'.

followed by no prompt. You should now type


	GET /faculty/jondich/cs107/index.html HTTP/1.1
	Host: www.mathcs.carleton.edu

followed by a blank line. This is a request for our course home page. You should now get a bunch of information about the file (this information is called the "header"), followed by the file itself in raw HTML form.

If you wait a few seconds, the HTTP server will close the TCP connection.

Step 4: The ICS discovers that not all files are available.

Try connecting to the HTTP server again, and request a file that doesn't exist.

Step 5: The ICS learns how to get a file's header information without getting the file itself.

Do a GET operation, but replace "GET" with "HEAD".

Step 6: The ICS wishes that these bizarre "in which" and "the ICS" constructions would end, already.

Log out.

Questions

Copy the following questions into a file named "telnet.txt" and insert your answers. When you are ready to submit your answers as homework, move telnet.txt into the S:\Students\homework\cs107\yourusername\ folder. You won't be able to see the file in that folder, but the grader will be able to get at it and grade it. If you make a mistake and want to resubmit your homework, change the name of the file to telnet2.txt and drag it into the same folder. The grader will grade the latest-numbered file.

  1. The "ls -l" UNIX command gives you information about each file in the current folder. What information does it give you?

  2. When you requested the file /faculty/jondich/index.html, what header information did you receive? Explain as well as you can what each line of the header means.

  3. When you requested a non-existent file, what error number and message did the server send back?

  4. When you connect to www.mathcs.carleton.edu, you receive the message "Trying 137.22.4.90...". This IP address, 137.22.4.90, uniquely identifies www.mathcs.carleton.edu among all the computers on the Internet. Try the following.

  5. Try giving the web server on www.mathcs.carleton.edu gibberish. What error number and message do you receive?