SIGN IN / UP
    opened image

    Telnet — is a network protocol that allows you to connect to remote workstations or servers and manage them through text commands, which is why it was developed in 1969. However, Telnet has one significant drawback — it transmits data in an unencrypted form, making it unsafe to use in modern networks.

    Today, many users are switching to more secure protocols, such as SSH (Secure Shell), which provides data encryption. At the same time, Telnet can still be used for educational and testing purposes, as well as for testing and diagnosing network connections.

    In this article, we will explain and demonstrate the process of installing and using Telnet in Ubuntu 24.04 LTS. We will also show how to use Telnet to check open ports and test mail servers.

     

     

    ​​​​​​​

     

     

    What is Telnet?

     

    Telnet — is a protocol for remote access to individual devices and servers, allowing the user to send commands to the server through a text interface. The protocol operates on a client-server principle, where the client establishes a connection to the server via a specified IP address and port.

    Although Telnet was often used for remote administration of servers, today it is considered unsafe due to the lack of data encryption. This means that any transmitted data, such as text messages or passwords, can be intercepted by malicious actors. For this reason, it is recommended to use SSH for connections and remote management.

    However, Telnet is still useful for the following purposes:

    • Testing network connections.

    • Checking port availability.

    • Diagnosing mail servers.

    • Using Telnet to check DNS

    • Testing HTTP requests

     

    Requirements for Installing Telnet

     

    Before starting the installation of Telnet, we need to ensure that our system meets the following requirements:

    • Operating System: Ubuntu 24.04 LTS (or other versions).

    • User Rights: Access to a system user with sudo rights.

    • IP Address: A static IP address for connecting via Telnet (optional, but recommended for stable operation).

     

    Installing the Telnet Client

     

    The Telnet client is necessary for connecting to remote systems using the Telnet protocol. To install the Telnet client in Ubuntu 24.04 LTS, follow these steps.

    Update the package list and install the Telnet client:

    sudo apt update
    sudo apt install telnet -y
    

    You need to ensure that Telnet is installed correctly by entering the command:

    telnet

    If you see a prompt with Telnet command line options, it means the installation was successful, as in our case.

     

    Installing the Telnet Server

     

    The Telnet server is necessary if you want to accept incoming connections via Telnet. This step may be required if you plan to use Telnet for remote management of the system.

    Install the Telnet server:

    sudo apt install telnetd -y

    Open the inetd.conf configuration file for editing:

    sudo nano /etc/inetd.conf
    

    Find the line related to Telnet and ensure that it is not commented out. If the line is commented out (# at the beginning), remove that character:

    telnet  stream  tcp  nowait  telnetd  /usr/sbin/tcpd  /usr/sbin/in.telnetd

    Save the changes and restart the service:

    sudo systemctl restart inetd.conf

     

    The Telnet server is now ready to accept connections

     

    Testing the connection to the Telnet server

    To test the connection to the Telnet server, follow these steps:

    On the remote system, open a terminal and execute the command to connect to the Telnet server:

    telnet

    If the Telnet server is configured correctly, we need to ensure this by receiving a prompt for entering a username and password.

    Enter the user data that has rights in the system. If everything goes well, we will be able to enter commands on the remote system via telnet.

     

    Using Telnet to Check Open Ports

     

    Telnet can be used to check open ports on a remote system. This is useful for diagnosing network issues and checking the availability of services.

    To check open ports, execute the command:

    telnet <port number>

    If the port is open and available, you will see a successful connection. If the port is closed, the system will return a connection error.

    Example of checking port 80 on a remote system:

    telnet 192.168.1.1 80

    If the port is open, you will receive a response from the server that the connection is established. If not, the system will inform you that the connection failed.

    But you can check whether a port is open or not not only on a remote system, 

     

    Checking the Mail Server Using Telnet

     

    Telnet can be used to check the operation of mail servers, such as SMTP. This helps to ensure that the server correctly receives and processes email messages.

    To connect to the mail server (SMTP), execute the command:

    telnet 25

    Once we are connected to the server - execute the EHLO command:

    EHLO example.com

    Next, test sending an email using the commands:

    MAIL FROM:<[email protected]>
    RCPT TO:<[email protected]>
    DATA
    

    Write the text of the email and finish input by pressing Ctrl+D.

    These commands will help check whether the SMTP server is functioning correctly and whether it is possible to send mail.

     

    Testing HTTP Requests

     

    Telnet can help in debugging web servers. For example, you can manually send an HTTP request:

    telnet www.example.com 80

    After establishing a connection, manually enter the HTTP request:

    GET / HTTP/1.1
    Host: www.example.com
    

    Press Enter twice to see the server's response.

     

    Using Telnet to Check DNS

     

    Although this is not the primary way to work with DNS, Telnet can help in checking DNS queries through ports 53 (UDP) and 953 (TCP). For example:

    telnet dns.example.com 53

    This can be useful for diagnosing problems with the DNS server.

     

    Conclusion

    Telnet can still be useful for testing and diagnosing network connections. However, due to the lack of encryption, it is not suitable for remote management of servers in real-world conditions. It is recommended to use Telnet only for educational or testing purposes. To ensure data security, it is best to use SSH, which is the modern standard for remote server management.