The telnet command is a great and handy Linux network service communication utility. From remote server and system port scans, to debugging network connections, telnet offers easy text-based interaction with a remote host.
In this step by step guide, you can see how to install, configure, and utilize telnet on Linux server. We shall also discuss its various options and features so that you can have a complete idea.
Choose your server now!
telnet, or "Telecommunication Network," is a remote network protocol on another computer over the Transmission Control Protocol (TCP). telnet provides the ability to directly specify the remote host on a particular port so that commands may be sent and output directly read in real time.
telnet is employed primarily for:
Testing Open Ports: Determine if a server has an open port.
Accessing Services: Get direct access to the web, e-mail, or other networked services.
Troubleshooting Network Issues: Fix network connectivity issues or port not available issues.
telnet is not pre-installed on most modern Linux distributions. Installation depends on your system type.
An Ubuntu or any Debian-based Linux user can install telnet with the apt package manager:
sudo apt install telnet
telnet can be installed on RedHat, CentOS, or Fedora by using the yum or dnf package managers:
sudo yum install telnet
For newer versions:
sudo dnf install telnet
The telnet command syntax is simple:
telnet [hostname/IP] [port]
Where:
[hostname/IP]: Specifies the hostname or IP address of the remote host.
[port]: Specifies the port number you want to connect to. It can be omitted, and the default port (23) is used.
telnet establishes one direct connection to services on specific ports, like HTTP (port 80), SMTP (port 25), or FTP (port 21).
The telnet command is highly customizable, offering several options that enhance its usability and functionality.
|
Option |
Description |
|
|
Forces |
|
|
Forces |
|
|
Allows transfer of 8-bit data via |
|
|
Disables the |
|
|
Prevents |
|
|
Enables the loopback mode so that |
|
|
Specifies the authentication type (i.e., |
|
|
Automatically fills in the user's login name attempting to log onto the remote system. |
|
|
Enables debugging mode, providing detailed information about the connection process and communication. |
|
|
Alters the escape character for |
|
|
Specifies the username for the login attempt. |
|
|
Writes session activity to a specified trace file for debugging or logging. |
|
|
Defines a local interface or address for |
|
|
Creates a reverse |
telnet provides diagnostic and testing capabilities for networks. Some of these include:
telnet is often used to verify if a specified port of a server is open. To verify port 80, enter the following command:
telnet example.com 80

If the port is open, telnet will connect, and you might have a blank screen expecting input. This is a good indication that the port is listening and expecting to chat. If the port is firewalled or closed, you would get an error message such as "Connection refused."
telnet can debug email servers by sending raw SMTP commands. To open an SMTP server on port 25:
telnet mail.example.com 587

Once connected, you can directly type SMTP commands such as HELO, MAIL FROM, and RCPT TO to communicate with the server. For example:

telnet enables manual HTTP requests to debug web servers. For example:
telnet example.com 80

After connecting, type:
GET / HTTP/1.1
Host: example.com
Press Enter twice to send the request, and the server's response will appear.

If the server supports both IPv4 and IPv6, you can force the connection to use IPv4:
telnet -4 example.com 80

This ensures compatibility with IPv4-only networks.
telnet can connect to a MySQL database server to check if the port is open (default port 3306).
telnet database.example.com 3306
Replace database.example.com with the MySQL server address.
If the connection is successful, telnet will display a protocol-specific greeting message from the MySQL server.
Although telnet is a handy utility, it is fundamentally unsafe since it sends the data, including passwords, in cleartext. Consequently:
Don't Use Telnet Over Unsecure Networks: Utilize a secure, private network whenever possible.
Use Alternatives: Use SSH (Secure Shell) for encrypted communication.
Restrict Access: Turn off telnet on your servers if you do not use it.
By understanding these risks, you can take precautions to secure your systems.
telnet’s utility extends to a variety of specialized scenarios:
Monitoring Services: Use telnet to interactively query protocols like IMAP or POP3 to diagnose emails.
IoT Device Management: telnet can be utilized as an immediate interface to communicate with IoT devices that utilize text-based communication protocols.
Educational Use: It is an excellent learning tool for studying network protocols and server responses.
Despite its simplicity, telnet may run into issues such as:
Connection Refused: This would usually be so if the target port is firewalled or closed.
Time-Out Errors: These could reflect network delay or routing issues.
Permission Denied: Check appropriate user privilege and port availability.
Regularly checking server configurations and network settings can help resolve these issues.
If telnet's lack of encryption is a security risk to your system, there are several alternatives that offer comparable functionality with added security and features:
SSH (Secure Shell): SSH is the most common telnet substitute, providing secured communication, tunneling, and strong authentication. Use the ssh command to securely connect to remote servers.
Netcat (nc): Netcat is a full-featured networking debugging tool, port scanner, and connection tester. It can handle both TCP and UDP.
OpenSSL S_client: OpenSSL can be utilized to test SSL/TLS protocols securely on particular ports.
Choose your server now!
telnet in Linux is a simple and convenient network diagnostics and debugging tool. As long as you understand its security limitation and have sufficient configurations, telnet remains a convenient debugging tool, test tool, and communications tool for network services.
From this guide, you have a working configuration that strikes a balance between convenience and responsible caution. Get the best out of your Linux experience and control your systems securely and efficiently remotely.