NEXT UP previous
Next: ftp

telnet

The telnet program allows users to communicate between machines using the TELNET protocol. The most common use of telnet is to allow users to login to remote machines over the network. The general form of the telnet command to do this is:

	$ telnet host.domain

where host.domain is the fully qualified hostname of the system to which you wish to connect. If successful, this command will result in a login: prompt from the remote machine.

Once you are logged in to a remote machine then telnet behaves like a dumb terminal, so that any characters you type are just sent to the remote machine. That is, unless you enter the telnet escape sequence. By default, the escape sequence is Ctrl-] and if you enter this sequence, your terminal session will be interrupted and you will get the following prompt from your local telnet program:

	telnet>

Just pressing Enter at this prompt will reconnect you to the remote machine, so that your remote session can continue. There are many commands that can be entered at the prompt for controlling various aspects of your telnet session and they are fully detailed in the telnet manual page. For example, the command to change the escape character sequence is:

	telnet> set escape ^X
	escape character is  '^X'

After typing set escape you just type the character sequence to be used from now on (Ctrl-X in this example) and telnet responds by confirming your request and resuming your remote session.

All of the Internet services have default port numbers that the servers use and to which the clients must connect when they request a particular service. A list of the default port numbers can be found in the file:

	/etc/services

The default port for telnet is port number 23, so that, normally, your telnet program will automatically use this port when making a connection to the telnet service on a remote machine. However, you can use your local telnet program to make a dumb terminal connection to any other port number on a remote machine just by adding the required port number to the initial telnet command line:

	$ telnet host.domain port

where port will be replaced with the required number.

As an example, the following sequence shows telnet being used to send a mail message by communicating directly with the remote machine's mail transport program on the default e-mail port number, which is port 25:

	$ telnet Hawklord 25
	mail from: <pc>
        250 <pc>... Sender ok
	rcpt to: <saw>
	250 <saw>... Recipient ok
	data
	354 Enter mail, end with "." on a line by itself
	Hi
	This is just a test message...

	250 WAAOO321 Message accepted for delivery

The lines with numbers on the front are confirmation messages and prompts from the remote machine's mail transport program, and the rest of the lines are commands and message text typed into telnet on the local machine.


NEXT UP previous
Next: ftp