Methods for connecting to remote devices using the telnet command. TELNET—Basics of Use

With the advent of computers and networks, corresponding programs also appeared for remote control of the system and for transmitting data over a distance. First of all, such software is embedded inside the operating system in a standard form, which significantly alleviates the problem - no search for software for remote control is required. In order to connect to a specific computer from a distance, you can use a regular Windows console terminal, called the command line or otherwise known as cmd.

In order to contact a specific computer on the network remotely, you just need to take full advantage of the “telnet” command for remote control of the system. This command will provide not only information retrieval, but also control of all actions occurring in this system.

The "telnet" command is present on all versions of Windows. But not all versions of Windows have this command configured as required. For example, to use “telnet” on Windows 7, you need to make a number of simple settings to connect this module.

All that is required for the "telnet" command to be available is the presence of a network, as well as the system user's membership in the Administrators group. All settings are made through the menu items "services.msc". This service can be launched via search. When you launch it, you need to click on the “telnet” sign with the right mouse button and then select properties. In the properties you can make a wide variety of settings for a given connection, as well as change the startup type of this service. "Telnet" for Windows 7 contains three launch options: manual mode, automatic mode and shutdown mode.

If you access remote control using the input line, then the "telnet" command has a number of additional commands, thanks to which the user determines which computer on the network will be connected to, through which port, and the user can also enter the full path to any file or browse the entire directory using a regular command.

In order to take advantage of all the promising conditions of “telnet”, before connecting to it, you should make sure that the Firewall settings are correct, since any incorrectness in terms of settings can entail a lot of other consequences. Incorrect configuration, in turn, will not make it possible to implement

Another reason why the connection may fail is errors. They can be issued in connection with any failure in the system or due to incorrect settings. The reason for the lack of connection can be determined by the error code, since each of the errors issued will contain its own number, which, in turn, will help identify the malfunction and eliminate it. If this server is intended for constant use, then it is better to configure it every time you start the computer. Similarly, you can configure the server to start manually.

As you can already see if you read my post about setting up Telnet on Windows, working with this service is quite easy. You can run it without arguments by specifying only the host system address on the command line. Under certain circumstances, you still need to specify a specific port. The first message that the user sees after executing the “telnet” command is sent by the program itself, and after communication is established between the client and the server, messages originating from the managed system are displayed. In this regard, you can work with a remote operating system via Telnet in the same way as happens with other specialized programs for remote access to the OS. Now let's take a closer look at this service and look at the most commonly used Telnet commands.

The Telnet command line on a Windows client can accept the following commands:

open node port – used to establish a connection with a given node;

close – closes an existing connection;

quit – exit the current Telnet session;

display – allows you to view the current Telnet client settings;

set – with its help it is possible set Telnet parameters for the current session, and more specifically:

  • set ntlm will enable NTLM (using NTLM authentication integrated into Telnet when connecting a user from a remote computer allows you to avoid entering a login and password when logging in);
  • set localecho will enable local command output mode;
  • set term vt100/vt52/vtnt/ansi will set the specified terminal type (for example, VT100 is used to run regular command line programs, and VTNT is used to run advanced programs, such as “edit”);
  • The set escape character will set a sequence of keys that switches the session mode to the command mode (for example, set escape , then pressing the “Ctrl+P” and “Enter” keys will set Ctrl+P as the switch);
  • set logfile filename will point to the log file of current Telnet activity (this file must be in the file system of the controlling computer);
  • set logging will enable logging (the log file must be specified in advance by the above command, otherwise an error message will appear);

unset – executes disabling various Telnet session options(inverse operations in relation to set), namely:

  • unset ntlm will disable integrated authentication;
  • unset localecho deactivates local command output mode;

status – used to check if there is a connection to the Telnet client;

enter – used to go to an existing connected Telnet session;

Or help – displays help information.

Once you are done with your work on the remote machine, you will need to close the connection to it. However, Telnet itself does not always complete its work. To exit to the Telnet command line, use the hotkeys “Ctrl+]”.

Not all computer users are aware of the presence of hidden services that allow you to perform various operations without using special software. The Telnet service is present in Windows and Linux operating systems. This material will discuss in detail the purpose of the service, commands, capabilities and how to work with it correctly.

What is Telnet

Telnet is a means of communication that is established between terminal devices. An example of such a connection is quite simple: a personal computer and a server that supports a similar type of connection. Telnet is not any software, it is communication protocol. But it should be noted that there are some utilities that work via the “terminalnetwork” protocol.

In the recent past, Telnet was one of the main ways to connect to the network. Now the utility practically not used. Today, operating systems have more advanced protocols installed, eliminating any additional actions from the user.

This communication protocol is used in some operations:

  • connection to a remote desktop;
  • examination ports for connectivity;
  • usage software that is only available on remote machines;
  • application system directories, which can only be opened using this type of protocol;
  • sending email without using additional software;
  • users using this protocol allows other users gain access to your personal computer.

Installation and launch

There is no need to download the utility; Telnet is built into Windows 7/8/10 by default.

Installation and startup instructions:

In order to start the client you need to open the command line:

We invite you to watch the video on installing Telnet in Windows:

Port check

Checking a network port to see if a personal computer can access it in Telnet:

  • in the window you need to enter the telnetip command;
  • followed by enterIP address computer, for example, 192.168.1.1. You can view the address in the settings of your network router;
  • At the end, enter the FTP port “21”. Thus the command will look like this: telnet 192.168.0.1 21;
  • after that it will appear error message if the port is unavailable or asking you to enter additional data if the port is open.

Telnet Commands

Utility commands are a way to interact with it. To display list of all commands, you must enter “help”. Next, we will look at the main commands in detail:

  • “open” - the request allows connect to a remote server;
  • "close" - process interruption connecting to a remote server;
  • "set" - setting server connection parameters;
  • "term" - the request is intended for terminal type indications;
  • "escape" - sets control character;
  • "mode" - choice operating mode;
  • "unset" - reset previously entered parameters;
  • "start" - launch servers;
  • "pause" - temporary stop server operation;
  • "continue" - continuation of work servers after a pause;
  • "stop" - complete work stoppage server.

Telnet on Linux

Like Windows, Telnet is built into the Linux operating system. Previously it was used as the standard Telnet protocol, now it has been replaced by the more improved SSH. As with the previous OS, the utility in Linux is used to check ports, routers, etc.

Let's look at the main operating modes:

  • « line by line" This operating mode is recommended. In this case, editing the request is carried out on the local PC and is sent to the server only when it is ready;
  • « character-by-character" Every character typed in the console window is sent to the remote server. You cannot edit the text here. When you delete a character using “Backspace”, it will also be sent to the server.

Basic commands in Linux:

  • “close” — interrupt the connection;
  • “encrypt” — enable encryption;
  • “logout”—turn off the utility and close the connection;
  • “mode” — selection of operating mode;
  • “status” — connection status;
  • “send” — sending a telnet request;
  • “set” — setting server parameters;
  • “open” — connection to a remote server;
  • “display” — display of special characters.
  • in the console window enter a request for server availability checks, for example, "telnet 192.168.1.243";
  • Next, let’s check access to the port by entering the request “telnet localhost 122” and “telnet localhost 21”. A message will appear on the console screen indicating whether any of the ports are accepting the connection;
  • example of remote control using telnet. To do this, enter the request “telnet localhost 23” in the main window. "23" is the default port. To perform remote control, you need to install “telnet-server” on your local computer. After this, a message will appear asking you to enter your login and password.

Disadvantages of Telnet

The main disadvantage of this protocol is the remote connection without using encryption. The only security point is the authorization of users in the telnet session. But nevertheless, the login and password are also transmitted in unencrypted form, so access to them can be obtained one way or another. It is strongly recommended not to transmit any important data over local networks.

Telnet is not an internal or external command

This error appears if this client is not installed on the personal computer. You need to do the following:


Second way:


Telnet Commands

Teams telnet allow you to communicate with a remote computer using the Telnet protocol. You can run the command telnet without parameters to enter the telnet context indicated on the Telnet command line ( telnet). From the Telnet command line, use the following commands to control the computer running the Telnet client.

Teams tlntadmn allow you to remotely control a computer running a Telnet server. These commands are executed from the command line. Team tlntadmn without parameters displays the local server setting.

To use commands telnet from the Telnet command line

To launch the Telnet client and enter the Telnet command line

Syntax

telnet [\\ remote server]

Options

\\ remote server Displays the name of the connected server /? Displays help on the command line.

Notes

  • When using the command telnet The Telnet client starts without parameters.
  • At the Telnet command line, you must use Telnet commands.

To stop the Telnet client

Syntax

Options

none

Notes

  • q.

To connect a Telnet client to a remote computer

Syntax

open [\\ remote server] [port]

Options

\\ remote server Specifies the name of the managed server. If no server is specified, the local server is used. port Indicates the port to use. If no port is specified, the default port is used.

Notes

  • This command can be shortened to o.

Examples

To connect to the remote Redmond server on port 44, enter at the command prompt:
redmond 44

To disconnect the Telnet client from the remote computer

Syntax

close [\\ remote server]

Options

\\ remote server Specifies the name of the managed server. If no server is specified, the local server is used.

Notes

  • This command can be shortened to c.

Examples

To disconnect from the remote Redmond server, enter the command:
c redmond 44

To configure Telnet client settings

Syntax

set [\\ remote server] [ntlm] [localecho] [term {ansi | vt100 | vt52 | vtnt}] [escape symbol] [logfile file name] [logging] [bsasdel] [crlf] [delasbs] [mode {console | stream}] [? ]

Options

\\ remote server Specifies the name of the managed server. If no server is specified, the local server is used. ntlm Enables NTML authentication, if available on the remote server. localecho Enables local display of commands. term {ansi | vt100 | vt52 | vtnt) Specifies a terminal of the specified type. escape symbol Specifies the control character. The control character can be a single character or a combination of the CTRL key and a character. To set a key combination, hold down the CTRL key while typing the character you want to assign. logfile file name Specifies the Telnet activity log file. The log file must be located on the local computer. Logging starts automatically after selecting this option. logging Enables logging. If a log file is not specified, an error message is displayed. bsasdel Specifies the BACKSPACE key to delete. crlf Assigns a new linear mode that defines the ENTER key as 0x0D, 0x0A. delasbs Assigns the DELETE key to delete the last character. mode {console | stream) Sets the operating mode. ? Allows you to view the full command syntax.

Notes

  • To disable a previously assigned setting, at the Telnet command prompt, enter:

    unset [parameter]

  • To assign a control character, enter the command:

    e symbol

  • In non-English versions of Telnet, the command is available codesetparameter. Codeset parameter specifies the current code set for the parameter, which can be one of the following: Shift JIS, Japanese EUC, JIS Kanji,JIS Kanji (78), DEC Kanji, NEC Kanji. You must assign the same code set on the remote computer.

To send Telnet client commands

Syntax

send [\\ remote server] [ao] [ayt] [esc] [ip] [synch] [ ? ]

Options

\\ remote server The name of the server that you want to manage. If no server is specified, the local server is used. ao Cancels an input command. ayt Sends the command “Are you there?” esc Sends the current control character. ip Interrupts execution of a processing command. synch Performs a Telnet synchronization operation. ? Allows you to view the full command syntax.

To view the current Telnet client settings

Syntax

display

Options

none

Notes

  • This command displays the current operating parameters for the Telnet client. When operating in Telnet session mode (in other words, while connected to a Telnet server), you can exit the session to change settings by pressing CTRL+]. To return to the Telnet session, press ENTER.

To use tlntadmn commands from the command line

To administer a computer running Telnet Server

Syntax

tlntadmn [\\ remote server] [start] [stop] [pause] [continue]

Options

\\ remote server start Starts the Telnet server. stop Stops the Telnet server. pause Interrupts the Telnet server. continue Resumes the Telnet server. /? Displays help on the command line.

Notes

  • Using commands tlntadmn tlntadmn

To administer Telnet sessions

Syntax

tlntadmn [\\ remote server] [-s] [-k{session_code | all}] [-m {session_code | all} " message" ]

Options

\\ remote server Specifies the name of the server that you want to take control of. If no server is specified, the local server is used. -s Displays active Telnet sessions. -k{session_code | all) Ends sessions. Enter a session code to end a specific session or enter all to end all sessions. -m {session_code | all} " message" Sends a message to one or more sessions. Enter a session code to send a message to a specific session, or enter all to send a message to all sessions. Type the message you want to send in quotes (i.e. " message" ). /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

To set event logging settings for the computer running Telnet Server

Syntax

tlntadmn [\\ remote_computer] config [auditlocation={eventlog | file | both}] [audit=[{+ | - } admin][{+ | - } user][{+ | - } fail]]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. auditlocation={eventlog | file | both) Specifies whether event information should be sent to the Event Viewer, to a file, or to both. audit=[{+ | - } admin][{+ | - } user][{+ | - } fail] Specifies which events require auditing (administrator logon events, user logon events, or failed logon attempts). To audit a specific event type, enter a plus sign (+) in front of the event type. To stop auditing of a specific event type, enter a minus sign (-) in front of the event type. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.
  • If you specify where to send event information without specifying the information type or types to be audited, only administrator log event information will be audited and sent to the specified location.

Examples

To send event information to the Event Viewer, enter:

tlntadmn config auditlocation=eventlog

To audit administrator logon events and failed logon attempts, enter:

tlntadmn config audit=+admin +fail

To set the primary domain for the computer running Telnet Server

Syntax

tlntadmn [\\ remote server] config [dom=domain name]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. dom=domain name Specifies the domain that you want to make primary. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

Examples

To make the Redmond domain the primary domain on your local server, enter:

tlntadmn config dom=Redmond

To map the ALT key to the computer running the Telnet server

Syntax

tlntadmn [\\ remote server] config [ctrlakeymap={yes | no}]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. ctrlakeymap={yes | no) Indicates whether the Telnet server should interpret the CTRL+A key combination as ALT. Enter yes to map a keyboard shortcut or no to refuse matching. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.
  • If the ALT key is not mapped, the Telnet server does not send the ALT keystroke to applications where it might be needed.

To set the maximum number of connections for the computer running Telnet Server

Syntax

tlntadmn [\\ remote server] config [maxconn=positive_integer]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. maxconn=positive_integer Sets the maximum number of connections. This number can be specified using any positive integer less than 10 million. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

To set the maximum number of failed access attempts for the computer running the Telnet server

Syntax

tlntadmn [\\ remote_computer] config [maxfail=positive_integer]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. maxfail=positive_integer Sets the maximum number of failed login attempts allowed for a user. This number can be specified using any positive integer less than 100. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

To set the operating mode for the computer running the Telnet server

Syntax

tlntadmn [\\ remote server] config [mode={console | stream}]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. mode {console | stream) Indicates the operating mode. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

To set the Telnet port for the computer running the Telnet server

Syntax

tlntadmn [\\ remote server] config [port=integer_value]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. port=integer_value Specifies the Telnet port. The port can be specified using any integer less than 1024. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

To set authentication methods for the computer running the Telnet server

Syntax

tlntadmn [\\ remote server] config [sec=[{+ | - } ntlm][{+ | - } passwd]]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. sec=[{+ | - } ntlm][{+ | - } passwd] Specifies whether NTML or password authentication is used, or both, to authenticate login attempts. To use a specific authentication type, enter a plus sign (+) in front of that authentication type. To prevent a specific type of authentication from being used, enter a minus sign (-) in front of that type. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.
  • NTML is an authentication protocol for transactions between two computers, one or both of which are running Windows NT 4.0 and earlier. Additionally, the NTML authentication protocol is used for computers that are not part of a domain, such as independent servers and workgroups.

To set the idle session timeout for the computer running the Telnet server

Syntax

tlntadmn [\\ remote server] config [timeout=hh: mm: ss]

Options

\\ remote server Specifies the name of the server that you want to manage. If no server is specified, the local server is used. timeout=hh: mm: ss Sets the elapsed time value in hours, minutes, and seconds. /? Displays help on the command line.

Notes

  • Using commands tlntadmn You can remotely administer a computer running Telnet Server if both computers are running Windows XP. Teams tlntadmn cannot be used to remotely administer a Telnet server running Windows 2000 from a computer running Windows XP.

Notes

  • To switch from the Telnet client to command mode, at the Telnet command prompt, press CTRL+]. To return to the Telnet client, press ENTER.

Telnet is a network utility that allows you to connect to a remote port on any computer and establish an interactive communication channel, for example, to send commands or receive information. We can say that this is a universal browser in the terminal that can work with many network protocols.

This utility was very often used in the past to remotely control a Linux computer, but then it was replaced by the secure SSH protocol. But telnet is still used, for example, for network testing, port checking, and also for communicating with various IoT devices and routers. In this article we will look at what telnet is, as well as how to use telnet to solve your problems.

As I said, this utility is designed to create an interactive connection between remote computers. It works using the TELNET protocol, but this protocol is supported by many services, so it can be used to manage them. The protocol is based on TCP, and allows you to send regular string commands to another device. It can be used not only for manual control but also for interaction between processes.

To work with this protocol we will use the telnet utility, it is very easy to use. Let's look at the telnet syntax:

$ telnet options host port

The host is the domain of the remote computer to connect to, and the port is the port on that computer. Now let's look at the main options:

  • -4 - force the use of ipv4 addresses;
  • -6 - force the use of ipv6 addresses;
  • -8 - use 8-bit encoding, for example, Unicode;
  • -E- disable support for Escape sequences;
  • -a- automatic login, takes the username from the USER environment variable;
  • -b- use a local socket;
  • -d- enable debugging mode;
  • -R- rlogin emulation mode;
  • -e- set the beginning character of the Escape sequence;
  • -l- user for authorization on the remote machine.

That's it for the telnet command to establish a connection. But connecting to a remote host is only half the battle. After establishing a connection, telnet can operate in two modes:

  • Line by line- This is the preferred mode, here the line of text is edited locally and sent only when it is completely ready. Not all services always have this option;
  • Character-by-character- all characters you type are sent to a remote server. It will be difficult to correct anything here if you make a mistake, because Backspace will also be sent as a symbol and a movement arrow too.

The use of telnet is to send special commands. Each service has its own commands, but the protocol has its own telnet commands that can be used in the telnet console.

  • CLOSE- close the connection to the server;
  • ENCRYPT- encrypt all transmitted data;
  • LOGOUT- exit and close the connection;
  • MODE- switch mode, from lowercase to character or from character to lowercase;
  • STATUS- view connection status;
  • SEND- send one of the telnet special characters;
  • SET- set the parameter value;
  • OPEN- establish a connection via telnet with a remote host;
  • DISPLAY- display the special characters used;
  • SLC- change the special characters used.

We will not consider all the commands, since you are unlikely to need them, and if you do, you can easily find them in the official documentation.

How to use telnet?

Next we will look at how to use telnet to solve your problems. Usually, the utility is already installed on most systems, but if this is not the case, then you can install telnet from the official repositories, for example, in Ubuntu:

sudo apt install telnet

Now let's move on to using the utility. Initially, it was used to remotely control a computer, but since the more secure SSH protocol was later developed, it was no longer used.

1. Server availability

The utility can still be useful when checking the availability of a node; to do this, simply pass it the IP address or host name:

telnet 192.168.1.243

You don't have to use telnet for this; ping is available.

2. Port check

Using telnet we can check the availability of a port on a host, and this can already be very useful. To check the telnet port run:

telnet localhost 123
$ telnet localhost 22

In the first case, we see that no one accepts the connection, but in the second, a message about a successful connection and a greeting from the SSH server are displayed.

3. Debugging

To enable debug mode and display more detailed information while running, use the -d option while connecting:

sudo telnet -d localhost 22

4. Telnet console

Using the telnet console is also an important point in understanding how to use telnet. In the main mode, you can execute commands on a remote server, but if you want to address the command specifically to telnet, for example, to configure its operation, you need to use a special character to open the console, usually the utility immediately tells you what this character is, for example, it is used by default "^[":

To activate it, you need to press the key combination Ctrl+[, then you will enter the telnet input prompt.

To see all available commands, you can type ?. For example, you can view the connection status:

telnet>status

There are other interesting possibilities here. Such things can be done on any connection using the telnet utility.

5. View the telnet site

One common way to use telnet is to test a website from the console. Yes, you won’t get a beautiful web page, but you can manually collect requests and see all the data sent by the server.

telnet opennet.ru 80

Then issue the command to the web server:

The web server will return the entire page, as well as the headers that are necessary for the browser to display it.

6. Telnet remote control

It is strongly recommended not to use insecure telnet for remote control because all commands and passwords can be eavesdropped by a third party. But sometimes, for example, for routers, telnet is still used for remote control. Everything works exactly the same as for other connections, only you need to use port 23, and telnet-server must be installed on the remote computer:

telnet localhost 23

Here you don’t even need to specify the port, because 23 will be used by default. Next, you need to enter your login and password, and then you will be able to execute commands on the remote system.

conclusions

In this article, we looked at examples of using telnet, as well as what this utility is, although it is no longer used for its main purpose, it can still be useful to many users and system administrators. If you have any questions, ask in the comments!