How to telnet to port

How to telnet to port

Как пользоваться telnet

Эта утилита очень часто использовалась раньше, для удаленного управления компьютером с Linux, но потом ей на замену пришел защищенный протокол SSH. Но telnet все еще используется, например, для тестирования сети, проверки портов, а также для взаимодействия с различными IoT устройствами и роутерами. В этой статье мы рассмотрим что такое telnet, а также как пользоваться telnet для решения своих задач.

Что такое Telnet?

Как я уже сказал, эта утилита предназначена для создания интерактивного соединения между удаленными компьютерами. Она работает по протоколу TELNET, но этот протокол поддерживается многими сервисами, поэтому ее можно использовать для управления ими. Протокол работает на основе TCP, и позволяет передавать обычные строковые команды на другое устройство. Он может использоваться не только для ручного управления но и для взаимодействия между процессами.

Для работы с этим протоколом мы будем использовать утилиту telnet, ею очень просто пользоваться. Давайте рассмотрим синтаксис telnet:

$ telnet опции хост порт

Это все, что касается команды telnet для установки соединения. Но соединение с удаленным хостом, это только полдела. После установки подключения telnet может работать в двух режимах:

Использование telnet заключается в передаче специальных команд. У каждого сервиса свои команды, но у протокола есть свои команды telnet, которые можно применять в консоли telnet.

Мы не будем рассматривать все команды, поскольку они вам вряд ли понадобятся, а если и понадобятся, то вы легко сможете их найти в официальной документации.

Как пользоваться telnet?

Дальше мы рассмотрим как использовать telnet для решения ваших задач. Обычно, утилита уже установлена в большинстве систем, но если это не так, то вы можете установить telnet из официальных репозиториев, например, в Ubuntu:

sudo apt install telnet

Теперь перейдем к применению утилиты. Изначально она использовалась для удаленного управления компьютером, но поскольку потом был разработан более безопасный протокол SSH, использовать ее перестали.

1. Доступность сервера

Утилита все еще может быть полезной при поверке доступности узла, для этого просто передайте ей ip адрес или имя хоста:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Для этого не обязательно применять telnet, есть ping.

2. Проверка порта

C помощью telnet мы можем проверить доступность порта на узле, а это уже может быть очень полезным. Чтобы проверить порт telnet выполните:

telnet localhost 123
$ telnet localhost 22

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

В первом случае мы видим, что соединение никто не принимает, во втором же выводится сообщение об успешном подключении и приветствие SSH сервера.

3. Отладка

4. Консоль telnet

Использование консоли telnet тоже важный момент в разборе как пользоваться telnet. В основном режиме вы можете выполнять команды, на удаленном сервере, если же вы хотите адресовать команду именно telnet, например, для настройки ее работы, необходимо использовать спецсимвол для открытия консоли, обычно утилита сразу говорит вам что это за символ, например, по умолчанию используется «^[«:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Для его активации вам нужно нажать сочетание клавиш Ctrl+[, затем вы уведите приглашение ввода telnet.

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Здесь есть и другие интересные возможности. Такие вещи можно проделывать при любом подключении с помощью утилиты telnet.

5. Посмотреть сайт telnet

telnet opennet.ru 80

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to portЗатем наберите команду веб-серверу:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Веб сервер вернет полностью страницу, а также заголовки, которые необходимы для ее отображения браузером.

6. Удаленное управление telnet

Настоятельно не рекомендуется использовать небезопасный telnet для удаленного управления, потому что все команды и пароли могут быть прослушаны сторонним пользователем. Но иногда, например, для роутеров telnet все же используется для удаленного управления. Все работает точно так же, как и для других подключений, только нужно использовать порт 23, а на удаленном компьютере должен быть установлен telnet-server:

telnet localhost 23

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to portТут порт можно даже не указывать, потому что по умолчанию будет использоваться именно 23. Далее, вам нужно ввести логин и пароль, а затем вы сможете выполнять команды в удаленной системе.

Выводы

В этой статье мы рассмотрели примеры использования telnet, а также что представляет из себя эта утилита, хотя она уже не используется по своему основному назначению, но до сих пор может быть полезной многим пользователям и системным администраторам. Если у вас остались вопросы, спрашивайте в комментариях!

Using telnet to Test Open Ports

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

When it comes to checking if a network port is opened or closed on a remote computer, there’s no easier way than to use Telnet. Ports that are left open for no reason are a security risk that can be exploited by malicious programs and viruses. At the same time, if a legitimate software communicates through a certain port, having that port closed will make the program throw errors and malfunction.

Many people find the challenge of checking if a port is opened to be too complex. However, one of the most efficient ways is to use the network protocol Telnet. Telnet allows the user to test individual ports and see whether they are open or not. In this article we’ll break down how Telnet can be used to check ports on Windows 10, Windows Server 2016, 2012 and 2008.

What is Telnet?

In a nutshell, Telnet is a computer protocol that was built for interacting with remote computers.

The word “Telnet” also refers to the command-line utility “telnet”, available under Windows OS and Unix-like systems, including Mac, Linux, and others. We will use the term “Telnet” mostly in the context of the telnet client software.

Telnet utility allows users to test connectivity to remote machines and issue commands through the use of a keyboard. Though most users opt to work with graphical interfaces, Telnet is one of the simplest ways to check connectivity on certain ports.

Enabling telnet client in Microsoft Windows operating systems

One of the most important things to remember is that Telnet is disabled by default in Window’s settings, so you need to turn it on before you can do anything. Turning it on will help you to run the required diagnostics and check if a port is open. If you try to use telnet without turning it on first, you’ll receive a message like:

In order to turn Telnet on, you need to use the command line or the graphical interface of your computer.

Enabling telnet client through Command Prompt:

If you want to enable Telnet via the command line, open the Command Prompt with elevated privileges (“as Administrator”) and run the following command:

Dism /Online /Enable-feature /FeatureName:TelnetClient

After you’ve put this in, Telnet will be ready to use to check your ports.

Alternatively to Command Prompt, you can use the following PowerShell command to achieve the same result:

If you want to use the graphical user interface you need to:

Windows 7, 8. 10:

Open Windows Start menu > Type «Control Panel» > Press Enter > “Programs” > «Programs and Features» > Turn Windows features on or off > Select «Telnet Client» > Press “OK»

Windows Server 2008:

Open “Server Manager” > Features > click “Add Features” > enable “Telnet Client” checkbox > click “Next” > click “Install” > when the feature installation finishes, click “Close”

Windows Server 2012, 2016:

Open “Server Manager” > “Add roles and features” > click “Next” until reaching the “Features” step > tick “Telnet Client” > click “Install” > when the feature installation finishes, click “Close”.

Using Telnet to Test Open Ports

One of the biggest perks of Telnet is with a simple command you can test whether a port is open. Issuing the Telnet command telnet [domainname or ip] [port] will allow you to test connectivity to a remote host on the given port.

Issue the following command in the Command Prompt:

telnet [domain name or ip] [port]

Put the IP address or domain name of the server you’re trying to connect to in place of [domain name or ip], and replace the second brackets with the port number on the remote machine, connection to which you want to test.

For example, to verify connection to 192.168.0.10 on port 25, issue the command:

telnet 192.168.0.10 25

If the connection succeeds, a blank screen will show up, meaning that the computer port is open.

A failed connection will be accompanied by an error message. It can indicate either a closed port or the fact that the indicated remote server is not listening on the provided port.

Example

telnet rpc.acronis.com 443

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Testing open ports with Telnet

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

How to Check if a Port is Open on Mac

High Sierra users: Apple removed telnet client from macOS 10.13 High Sierra. There is no official way to return it, but you can still copy it from an older OS or compile from sources and use on High Sierra. See more details here and here.

Just like on Windows, telnet can be accessed through Terminal, the command prompt on macOS. To open telnet, click “Go” > “Utilities” > «Terminal», then run the following command (the numbers are example IP address and port): telnet [domainname or ip] [port], e.g.>telnet 192.168.1.1 443

When a computer port is open a blank screen will show up, meaning that the connection has been successful. An unsuccessful connection will be accompanied by an error message.

An alternative to telnet in checking ports is Network Utility. In order to check ports on a Mac, follow the plan below:

Open «Network Utility» > Click «Port Scan» > Indicate the hostname and ports to scan the remote host e.g. myserver.com from 995 to 995 > Check the output

Acting on the results obtained from the Telnet test

Many times when you try to use Telnet, you may find that your own network is blocking your connection. It’s quite common for users to be running a firewall, which blocks connection, outbound ports. A basic way to test whether your firewall is interrupting your Telnet is to disable your firewall and run a Telnet test.

If you want to check for closed ports on your router, enter your router management console. Open a web browser and enter the IP address or name of the router, for example “192.168.0.10”. If the page does not open, try replacing “http” with “https” at the beginning of the address.

Next, enter your username and password, and click “Enter” or “Log in”. Head to the Security section to open or close ports and access other firewall settings of the router.

If you need to make resources in the internal network accessible from the outside, enter “External access”/”Port forwarding” section. Consult the router manufacturer’s documentation for the detailed instructions.

Related Acronis resources

Read further on what ports are used in Acronis software and how to open them:

Telnet to a Specific Port for Testing Purposes

The telnet program, which is not the Telnet protocol, can be useful to test port states which is the functionality this tutorial explains. The reason why this protocol is useful to connect to different protocols such as POP is both protocols support plain text (which is their main problem and why such services should not be used).

Checking ports before starting:

Before starting with telnet, let’s check with Nmap some ports on the sample target (linuxhint.com).

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Getting started with Telnet to specific ports for testing purposes:

Once we learned about open ports, we can start launching tests, let’s try the port 22 (ssh), on the console write “telnet

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

As you can see in the example below the output says I’m connected to linuxhint.com, therefore the port is open.

Let’s try the same on the port 80 (http):

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

The output is similar with port 80, now let’s try the port 161 which according to Nmap is filtered:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

As you see the filtered port didn’t allow the connection to be established returning a time out error.

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Once confirmed the port is closed, let’s test it with Telnet:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

As you can see the connection wasn’t established and the error is different than with the filtered port showing “Connection refused”.

To close an established connection, you can press CTRL+] and you will see the prompt:

Then type “quit” and press ENTER.

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Under Linux you can easily write a little shell script to connect through telnet with different targets and ports.

Open nano and create a file called multipletelnet.sh with the following content inside:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

Connections only start after the previous was closed, you can close the connection by passing any character, In the example above I passed “q”.

Yet, if you want to test many ports and targets simultaneously Telnet isn’t the best option, for which you have Nmap and similar tools

About Telnet:

As said before, Telnet is an unencrypted protocol vulnerable to sniffers, any attacker can intercept the communication between the client and the server in plain text accessing sensible information such as passwords.

The lack of authentication methods also allow possible attackers to modify the packages sent between two nodes.

Because of this Telnet was rapidly replaced by SSH (Secure Shell) which provides a variety of authentication methods and also encrypts the whole communication between nodes.

Bonus: testing specific ports for possible vulnerabilities with Nmap:

With Nmap we can go far more than with Telnet, we can learn the version of the program running behind the port and we can even test it for vulnerabilities.

Scanning a specific port to find vulnerabilities on the service:

The following example shows a scan against the port 80 of linuxhint.com calling Nmap NSE script vuln to test offensive scripts looking for vulnerabilities:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

As you can see, since it is LinuxHint.com server no vulnerabilities were found.

It is possible to scan a specific port for a specific vulnerability; the following example shows how to scan a port using Nmap to find DOS vulnerabilities:

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

How to telnet to port. Смотреть фото How to telnet to port. Смотреть картинку How to telnet to port. Картинка про How to telnet to port. Фото How to telnet to port

As you can see Nmap found a possible vulnerability (it was a false positive in this case).

You can find a lot of high quality tutorials with different port scanning techniques at https://linuxhint.com/?s=scan+ports.

I hope you found this tutorial on Telnet to a specific port for testing purposes useful. Keep following LinuxHint for more tips and updates on Linux and networking

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.

How can telnet connect to an arbitrary port?

Through telnet I am able to connect to any server at any port, how does it work? Is there a telnet server daemon running on that server? If there is, shouldn’t the daemon listen on a specific port? why can I connect to an arbitrary port on that server? Why can I telnet to 127.0.0.1 at 80 port and get a response from my Nginx without a telnet daemon running on my Ubuntu?

1 Answer 1

The telnet client doesn’t do any special processing. It opens a TCP connection to the remote server on any port you specify, forwards through this connection anything you type and puts on screen anything that it receives from the server.

When you telnet 127.0.0.1 80 it opens a connection to port 80 of localhost where usually a web server is already listening ( nginx in your case).

An HTTP client knows how to craft an HTTP request and send it through the connection. The telnet client doesn’t know anything about HTTP but if you know the protocol you can manually craft a request and type it and the telnet client will happily send it for you through the connection. If the program at the other end (the web server) understands the request it will send a response back. Again, the telnet client doesn’t understand a bit of the response (it’s just data to it) but it happily puts the response on screen.

You can use telnet to connect to any port of a (remote or local) computer, as long as there is a server application that is listening on that port.

The telnet server is deprecated by the SSH protocol that does the same thing (and many others) but everything that goes through the connection is encrypted on each end before sending and decrypted on the other end before being used. This adds privacy and security to the services already provided by the telnet server.

The telnet client, however, is still useful because it can be used to test the functionality of servers that use unencrypted text protocols like HTTP, SMTP, POP3, IMAP etc.

How to telnet to a port using telnet on Windows 10

Telnet is a small application that can be used on your local device to communicate using a textbase, command line, bidirectional interactive terminal. Telnet use port 23 as the default telnet port to send and receive text data over the network.

How to telnet to a port using telnet on Windows 10

How to telnet to a port using telnet on Windows 10

In Short Answer:

To telnet a port you can use the following command: telnet

Example: telnet openport.net 443

Here is a step by step guide:

Telnet was the chosen command line tool for communication over the network, you were able to open a connection using telnet to a remote device and, if the remote device had a telnet server installed on it you can run the command on that server.

In late time, telnet protocol is less in use due to lake of security, telnet sends a receive pure text that is not encrypted and that why most of the terminal communication move to the Secure Shell known as SSH.

Telnet Port:

Telnet uses a default port for communication, the default telnet port is 23, but you can use telnet on any other port you want. As telnet is a command line interface tool that expects parameters you can set the port you want to connect to.

How to telnet a port:

First, let’s check if telnet is installed on our system. To do so, we need to open the command line interface. You can do it in several ways.

Open the command line – option 1:

1) Press the Windows logo button on the keyboard.

2) Start typing cmd

3) You will see the command prompt app.

Open command prompt option 1

Open command prompt option 1

5) Once you press the Open the command line interface will open:

Command prompt screen

Command prompt screen

Open the command line – option 2:

1) Press the Windows+R combination (Windows logo button on the keyboard + R) to open the Run windows.

2) Type in cmd and press enter or click OK.

The Run Command Window

The Run Command Window

Running the telnet command:

Once you have your command line windows open you can type in telnet to check if telnet is installed on your system.

If telnet is not installed on your system, please refer to installing telnet on windows 10 section to installing it

In the following example, we use telnet /? command that will show us the help options for the telnet command.

Telnet help screen

Telnet help screen

If you only type telnet and it installed on your system it will enter you into the telnet interactive session. To exit from this terminal to the command prompt again type quit and press enter.

To telnet a port you can use the following command: telnet

Example: telnet openport.net 443

How do you know if the port is open or not? from the return answer. If you see the following text in your command prompt screen it means that the remote port is close.

Could not open connection to the host, on port

Telnet connection error message

Telnet connection error message

If the connection was established you will see a blank screen. To exit this screen, you can try to type quit and press enter or wait for the time out. You can also close the command prompt screen by pressing the x.

Telnet connection established screen

Telnet connection established screen

Installing Telnet on Windows 10:

In case you need to install telnet client on your local Windows 10 device, you will see the following error message when trying to run the telnet command: ‘telnet’ is not recognized as an internal or external command, operable program or batch file.

Telnet not found message

Telnet not found message

You will have to install it, here are the steps to install telnet client on your system:

1) Press the Windows logo button on the keyboard.

2) Start typing turn features

Turn windows features

Turn windows features

3) Open the Turn Windows features option.

4) In the Windows Features window that is opening, wait for it to load and scroll down till you see telnet client.

5) Mark it and press OK.

6) It might take several minutes and telnet will be installed on your system.

Windows Features Screen

Windows Features Screen

Conclusions:

In this how to telnet to a port using telnet on Windows 10 article, we take you step by steps in how to use the telnet command line tool on windows 10 to check a remote port.

You were able to learn the following:

You can refer to our guide article if you want to learn more.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *