Connect to a remote computer using telnet

Source: Internet
Author: User
Tags telnet program

A major advantage of Internet systems is that it is as convenient to manipulate computers on the other end of the world as it is to use computers on the other side. This chapter describes how to use the telnet service system to connect to a remote computer.
We will discuss two main ways to use remote computers. First, you can register on any Internet host to obtain your account header. For a Unix computer, you must have a user ID and password. Once registered, you can use the host normally. Second, many Internet computers provide a public Telnet service. This system is valid for any user and generally does not require a password.
You will find that Telnet will make you forget the distance between yourself and the remote host. All you can feel is that when the Internet is used frequently, the computer's response speed is slightly slow. Of course, skilled users can easily access several different Internet hosts in turn.
Telnet Overview
Telnet provides a large number of standards-basedProtocol. The service that connects you to a remote Internet host is called "Telnet ".
To use the telnet service, you must run a special telnet program on your computer. This program connects to your specified computer through the Internet. Once the connection is successful, Telnet works as an intermediary between you and another computer. Everything you input on the keyboard will be transmitted to another computer, And everything displayed on the other computer will be sent to your computer and displayed on the screen. As a result, your keyboard and screen seem to be directly connected to a remote computer.
In telnet, your computer is called a local computer, and the telnet program is connected to another computer called a remote computer ). These terms are used no matter how far the other computer is, whether in the same office or across the world. As described in Chapter 2, we often call an Internet computer a "host ". Therefore, using telnet, we can say that the function of the telnet program is to connect your local machine to a remote Internet host.
In addition, we usually use Telnet as a verb. For example, if you are visiting a friend's house outside China, you can say to him, "Can I use your computer? I want to telnet my computer to see if there is any email ."
The first method to run the telnet program
You should use the telnet program for remote connection. There are two methods to run the program. Here we will first describe one of the most commonly used methods. The next part will introduce another method.
Run the telnet program. First, enter the command name and the address of the remote machine you want to connect. For example, if you want to connect to a computer named fuzzball whose full address is fuzzball. UCSB. Edu, enter:
Telnet fuzzball.ucsb.edu
If you are connected to a computer on the local network, you can enter only the name of the machine instead of the full address. Example: Telnet fuzzball
As described in chapter 4, all Internet hosts have a formal IP address, which consists of a string of numbers separated by periods. For example, the IP address of a computer whose standard address is ucsd.edu is 128.54.16.1.
Some systems may have difficulties in processing certain standard addresses. If you encounter such problems when using the telnet program, you can try it with an IP address. For example, the following two commands can be connected to the same host for the same purpose.
Telnet ucsd.edu
Telnet 128.54.16.1
For more information about IP addresses and Internet addresses, see Chapter 4.
After running the telnet program, it starts to connect to the specified remote machine. When telnet is waiting for a response, the screen will display:
Trying...
Or similar information.
Once the connection is determined (if the host is far away, it may wait for a while), you will read this message: connected to fuzzball.ucsb.edu
Escape Character is ''^]''
(We will explain this instruction in the next "coder)
If you cannot determine the connection through telnet, you will get information that the host cannot find. For example, assume that you want to connect to the remote host, "nipper.com", but you mistakenly enter:
Telnet cnpaf.net
You will see:
Cnpaf.net: Unknown hosttelnet>
In this case, you can specify another host name or stop the program.
Many factors may make Telnet unable to connect remotely. The three most common factors are misspelling of computer addresses.
Remote computers are currently unavailable.
The computer you specified is not on the Internet.
In addition, some problems may occur: for some reason, your local network may not be connected to some parts of the Internet. One reason is that some hosts are isolated for confidentiality. Another reason is that some hosts cannot be connected to other hosts at all.
For example, a friend from Ireland complained that he could not connect to a computer in Australia. In this case, Telnet displays information similar to the following:
Host is unreachable
In this case, check whether the Telnet command or address is entered correctly.ManagementStaff, are there any other skills you don't know about this connection. Of course, if your location cannot be connected to a remote machine, you have to acknowledge the reality. (We had to say to the Irish friend: Many people have never been connected to Australian computers, but they still live a full and pleasant life .)
Once the telnet connection is confirmed, you can talk to the remote machine. At this time, many hosts will display some information, which is usually used to confirm the computer. Once the logon is accepted, you will see a standard prompt. For example, if you have been connected to a Unix remote machine, you will see:
Login:
Now you can log on in the regular mode. Enter your user ID and press Enter. You will see:
Password:
Enter your password and press Enter. (Note: The password you enter is not displayed on the screen. This is to prevent others from stealing your use right ).
We have pointed out that some remote machines can provide a public service, in which case you do not need to use a secret password when logging on. For example, in chapter 13th, we will discuss an Internet resource called Archie server. When you connect to the Archie server, an Archie user ID is used. Once this user ID is entered, the Archie program runs automatically. Some public hosts are even more convenient. As long as you use the Telnet command to connect, the remote program will be automatically executed, and you do not even need to enter the user ID and password.
After the remote machine is finished, you only need to "exit" in the conventional mode. The connection is disconnected and telnet stops running automatically.
The second method for running the telnet program
We have mentioned two methods to run the telnet program. The first method is to enter the Telnet command and the address of the remote machine. For example, Telnet fuzzball.ucsb.edu. The second method is to run Telnet without specifying the host address. Only input:
Telnet
At this time, the program runs, but no connection is made. You will see:
Telnet>
This is a telnet prompt. It indicates that the program is running and waits for you to enter a command. To connect to a remote machine, enter open and attach the address of the remote machine. For example:
Open fuzzball.ucsb.edu.
The connection effect is the same as when you enter the Telnet command and then specify a remote machine.
In the previous section, we gave an example. Telnet command input error address. In this example, the remote machine name is "nipper.com", but the error message is as follows:
Telnet cnpaf.net
At this time, Telnet still tries to connect. When the program fails, the connection is abandoned and a prompt is displayed, waiting for you to enter a command. In this case, you will see:
Cnpaf.net: Unknown host
Telnet>
Now you can enter an open command and the correct address:
Open nipper.com
If the address does not work, you can try another one. If you decide to give up, enter: Quit
Exit the telnet program.
Run and exit telnet:
There are two methods to run Telnet. First, add the remote host address after entering the command:
Telnet fuzzball.ucsb.edu.
The other is to enter only the command name:
Telnet
Enter an open command at the "telnet>" prompt:
Open fuzzball.ucsb.edu.
There are two methods to exit the telnet program. If you have been connected to a remote machine, use the conventional method to exit and the telnet program to exit automatically. Alternatively, enter the abort command at the "telnet>" prompt.
Quit
Connect to a specific number
In the Internet, many hosts can provide public services for telnet. In fact, if you check the directory, you will find that a large number of projects are accessed through Telnet.
Many remote hosts require you to specify a special "interface number" during connection to identify the service type you need. Here is an example:
The University of Michigan has a computer that provides weather forecasts for the United States and Canada. The machine name is downwind.sprl.umich.edu. When you connect to the machine, you must specify an interface number of 3000 to tell the machine that you want to use the weather forecast service.
All you need to do is add the interface number after the Telnet command:
Telnet downwind.sprl.umich.edu 3000
(Note that a space is left between the address and the interface number .) If you use the open command after the telnet> prompt to connect, enter interface numbers in the same way:
Open downwind.sprl.umich.edu 3000
When you use interfaces to connect to a remote machine, the program you need starts to run. After the program runs, the connection is disconnected and the telnet program automatically exits.
In this chapter, we describe Telnet commands based on most Unix systems. In other systems, the format may be different. For example, on a VAX computer using the VMS operating system, you must add "/Port =" before the interface number ":
Telnet downwind.sprl.umich.edu/Port = 3000
If you have any questions about your computer, the best way is to check the Telnet information. Further explore interface numbers
In computer terms, the term "interface" refers to the connection between two devices or systems. For example, you can connect a printer to the interface behind the computer. in UNIX, we say that each terminal is connected to its own interface on the host.
The same concept is also used in Internet terms. In chapter 2, we mention thatTCP(Transmission Control)ProtocolTransfers data from one host to another. Use at any timeTCPTo connect an Internet host to another host, you must use an interface number to identify the connection type. In fact, there is a formal Internet organization, that is, numbersManagementThe Board develops a set of accepted interface numbers and ensures that they are unique numbers.
When there is a shortage of time, the telnet connection usually uses the interface number 23, that is, when you do not specify the interface number, the telnet program automatically connects to the interface number 23. Therefore, the connection results of the following two commands are the same:
Telnet fuzzball.ucsb.edu
Telnet fuzzball.ucsb.edu 23
To connect to a remote machine, the remote machine must run a program that can communicate with the interface you are using. When the program is waiting for a connection, we call it "receive" on this interface ".
Therefore, any internal host that supports Telnet connection must have a program received on interface 23. That is to say, when you use the telnet program for regular connection to a remote machine, it will contact the remote machine and check whether there is a program "receive" on interface 23 ".
You must specify an actual interface number only when you want to use Telnet to connect to other interfaces. Many Internet systems use different interface numbers to provide some special services.
In the previous section, we used the interface number 3000 to connect to a remote host named downwind. SPRL. umich. edu. We do this to use a special program to display weather forecasts. To make the connection successful, you must run the weather forecast program in the remote host and the program should be received on interface 3000. In many cases, a host can support more than one connection at the same time on a specific interface. For example, the preceding special weather forecast server can support 100 users at the same time.
Telnet coder: Ctrl-]
When you talk to a remote machine, there is a way to interrupt your work and directly input additional commands to telnet. For example, if you have difficulty communicating with a remote machine, you can interrupt your work conversation and switch back to the Telnet status, and then enter the quit command.
Press ctrl-] as a special combination key. Press ctrl and then press. When you press this key combination, it sends a signal to telnet, pause the remote connection, and display the prompt:
Telnet>
Now you can enter any Telnet command at Will (several important commands will be introduced later ). After some commands are run, you can run telnet to automatically restore the remote connection. In addition, after the telnet> prompt, you can press the Enter key to restore the connection at any time.
A key such as Ctrl-] is called a "coder" in technical terms ". Many programs allow the use of a code to request special services.
In the Unix world, the "^" character is used to represent the ctrl key. For example, CTRL-C writes ^ C.
Now we can understand the information displayed on the screen after Telnet determines the remote connection: Escape Character is ''^]''
This prompt reminds you that the Telnet code is Ctrl-]. Of course we can also change it to another character, but this is usually not necessary.
Telnet command
You can choose to use different commands at any time after the telnet> prompt. This section describes some of the most important commands. First, we also want to remind you that, without entering any command, you only need to press the Enter key. Telnet will reconnect to the remote connection.
To display the abstract of all Telnet commands, can you enter it? Character:
?
The following is a typical summary:
Commands may be abbreviated, commands are :( abbreviation command, command :)
Closeclose current connection (close connection)
Displaydisplay operating parameters (display operation parameters)
Modetry to enter line-by-line or character-at-a-timt mode (trial networking)
Openconnect to a site)
Quitexit telnet (Exit)
Sendtransmit special characters (''send? ''For more) (transfer special characters)
Setset operating parameters (''set? ''For more) (set operation parameters)
Statusprint status information (print real-time information)
Toggletoggle operating parameters (''toggle? ''For more) (repeated operation parameters)
Zsuspend telnet (paused)
? Print help information)
Among all these commands, the most important ones are :?, Open, close, quit, and Z. The open command tells telnet to connect to a remote computer. After entering open, add the specific address of the computer. For example:
Open fuzzball.ucsb.edu
The close command terminates the remote connection but does not stop the telnet program. The following example shows its usefulness:
Suppose you are working on a remote machine and there is a fault. For some reason, the remote machine does not seem to accept your command. No matter what commands you enter, the remote machine does not respond, and you cannot even exit. One solution is to press Ctrl-], wait for the telnet> prompt, and enter the close command. Now you can reestablish a connection with the same host. Of course, you can also connect to another host.
The quit command is used to abort the telnet program. If a remote connection program is still running, quit will terminate it. Before you close a connection or exit telnet, remember to log out on the remote host. Most hosts will automatically cancel you after the connection is interrupted, but this operation will be better. This ensures that any program you run Exits normally and all data is stored.
The remaining commands are not very important (except the Z commands we will introduce in the next section), and you may never use them. Most of these commands are the technical features used to control communication conversations, and you may not notice them. If you want to display a further summary of the send, set, or toggle command, you can add? Character. For example:
Send?
For more information about telnet, see the system information. If you are using a Unix computer, you can use the following command to display it on the online manual
Telnet terms:
Man Telnet
Job Control
UNIX systems support a function called Job control. It allows you to pause a program and work on another program, and then return to the first program. Here we will not discuss the Unix functions in detail, but we will introduce how Telnet works with your system if there is job control.
Enter the Z command at the Telnet prompt (and then explain the meaning of the command name ). It will tell telnet to suspend work and return to "shell" (that is, the program that reads and processes your command ). In this way, you can enter Common commands during the remote conversation.
Only when your shell supports job control can the Z command work. If you use a modern shell, such as C shell or Korn shell, it can work. However, if you are using a relatively old Bourne shell without job control, the Z command will not work. In fact, the telnet program also "freeze" itself ).
The program you are currently running is called "foreground ". When you exit a program, we call it "background ".
When you enter the Z command, the telnet program places itself in the background and allows you to return to the local shell (local shell), so that you can enter the regular Unix Command at will. For example, you can check your email, display time, date, and so on. When you want to restore the remote connection, enter the following command:
FG
This command tells the UNIX System to re-enable the last interrupted program and place it on the foreground. Now you can restore the remote connection.
You may wonder why the Telnet job control command name is Z? This is because, in UNIX systems that support job control, you can press the susp (pause) Key to place the current program in the background. Generally, the key is Ctrl-Z. Therefore, the Telnet command is named after the Unix key.
If you do not perform any operations within a specified period of time, many hosts will automatically let you exit. For example, if you do not enter anything in a system within 15 minutes, the system will let you quit. Pay attention to this when you use the Z command to interrupt the Telnet conversation. If you fail to resume the remote conversation within the specified time, the connection will be automatically disconnected.
Figure 7-1 provides an example.
At the beginning of the example, we log on to a computer named "nipper. You can see the shell prompt:
Nipper
At this prompt, enter a Telnet command to connect to a remote computer named fuzzball .ucsb.edu:
Telnet fuzzball.ucsb.edu
Once the connection is confirmed, fuzzball displays the standard UNIX logon prompt. We use the user ID Harley to log on. Note that the entered password is not displayed to keep it confidential. After logon, the remote machine displays some information and a shell prompt is attached to it:
Fuzzball
Now we enter the data command to display the time and date.
Nipper Telnet fuzzball.ucsb.edu
Trying...
Connected to fuzzball.ucsb.edu
Escape Character is ''^]''.
Ultrix v4.2a (rev.47) (fuzzball)
Welcome to the fuzzball System
Login: Harley
Password:
Last login: Sun Apr 18 00:09:58 from nipper.com
Fuzzball date
Sun Apr 18 00:24:54 CDT 1993
Fuzzball Ctrl-]
Telnet> Z
Stopped
Nipper mail
No mail for Harley
Nipper FG
Telnet fuzzball.ucsb.edu
Fuzzball logout
Connection closed by foreign host.
Nipper
Figure 7-1 use Telnet for Job Control
Next, we want to temporarily return to the nipper machine to check for emails. First, press Ctrl-] to disconnect the remote connection and return it to telnet. You will see the prompt:
Telnet>
Then we enter the Z command, which places the telnet program in the background. Now we can see the shell of the nipper
Prompt. Then use the MAIL command (see chapter 6) to check whether there is any email information. Enter the FG command. The shell response is the last command that is placed in the background (in this example, the Telnet command ). Shell then puts the program back to the foreground to automatically restore the remote connection. We will see the fuzzball shell prompt again.
Finally, we enter the logout command to exit from fuzzball. The remote connection is automatically closed and the telnet program exits. We will return to the beginning of the nipper shell prompt.
In Unix systems, shell is a program that reads and processes your commands. There are many types of Unix shell, you can choose one.
When shell is ready to receive commands, it will display a prompt. If you have an account on multiple computers, you are advised to enter a prompt in a certain format so that it can contain the name of the computer (not detailed here ). In this way, your shell prompt can tell you which shell you are using at any time.
By convention, the last character of the prompt represents the shell type you use. In this example, the character is C-shell. $ Indicates the Korn shell or the Bourne shell.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.