Comprehensive Guide to Telnet Command in Linux: Usage, Installation, and Security Considerations

Telnet (Teletype Network) is one of the first protocols that defined remote system administration. Created in the late 1960s and standardized in 1973, it enabled users to connect to remote machines through a command-line interface, functioning as a virtual terminal over TCP/IP networks. By default, Telnet runs on port 23, transmitting commands and receiving text responses in real time.

In the ARPANET era, Telnet was essential for researchers and administrators, allowing simple, universal access across mainframes, minicomputers, and early PCs. However, its design lacked encryption, a limitation that became critical once networks expanded into today’s open internet.

Before considering telnet in linux, it is vital to recognize its risks: all data, including credentials and commands, is sent in plain text and easily intercepted. Due to these vulnerabilities, standards like PCI DSS and HIPAA forbid Telnet. SSH is the secure alternative, offering encryption, authentication, and integrity protection.

Comprehensive Installation Guide for Linux Distributions

The installation process for telnet linux components varies significantly depending on your distribution's package management ecosystem and version. Understanding these differences is crucial for successful implementation across diverse Linux environments.

Detailed Installation on Red Hat Enterprise Linux and Derivatives

Red Hat Enterprise Linux (RHEL), CentOS, Fedora, and their derivatives utilize sophisticated package management systems that have evolved over the years. For legacy systems running CentOS 7 and RHEL 7, the YUM (Yellowdog Updater Modified) package manager remains the standard tool for software installation and management.

To install both Telnet client and server components on these systems, execute:

yum install telnet telnet-server -y

The -y flag automatically confirms the installation, preventing interactive prompts that might interrupt automated deployment scripts. This command installs not only the basic Telnet client functionality but also the server daemon necessary for accepting incoming Telnet connections.

Modern Red Hat-based distributions, including Fedora 22 and later, RHEL 8+, CentOS Stream 8+, and Rocky Linux, have transitioned to DNF (Dandified YUM) as their primary package manager. DNF offers improved dependency resolution, better performance, and enhanced security features compared to its predecessor.

For these modern systems, use:

dnf install telnet telnet-server -y

After successful installation, the Telnet service requires explicit activation and configuration to begin accepting connections. The systemd service manager, standard across modern Linux distributions, provides comprehensive service lifecycle management:

systemctl start telnet.socket

systemctl enable telnet.socket

The first command immediately starts the Telnet service, while the second ensures it automatically starts during system boot. The .socket unit type indicates that systemd will manage the network socket, automatically spawning Telnet daemon instances when connections arrive.

Firewall configuration represents a critical security consideration. Most modern Linux distributions ship with restrictive firewall policies that block incoming connections by default. To allow Telnet traffic, you must explicitly open port 23:

firewall-cmd --permanent --add-port=23/tcp

firewall-cmd --reload

The --permanent flag ensures the rule persists across system reboots, while --reload immediately applies the configuration changes without disrupting existing connections.

Verification of proper installation and configuration can be performed using:

systemctl status telnet.socket

This command displays comprehensive status information, including whether the service is active, any error messages, and recent log entries that might indicate configuration problems.

Ubuntu and Debian-Based System Installation

Ubuntu, Debian, and their numerous derivatives utilize the Advanced Package Tool (APT) ecosystem for software management. This system provides excellent dependency resolution, security update management, and integration with the broader Debian package repository infrastructure.

To install Telnet server functionality on these systems:

sudo apt update

sudo apt install telnetd -y

The apt update command refreshes the local package database, ensuring you receive the latest available versions and security updates. The telnetd package provides both client and server functionality in most Debian-based distributions.

Service status verification uses the same systemd commands as Red Hat-based systems:

systemctl status inetd

Note that some Debian-based systems use inetd (Internet Super-Server) or xinetd to manage Telnet connections rather than dedicated systemd units. These "super-servers" listen on multiple ports and spawn appropriate service daemons when connections arrive, providing efficient resource utilization for infrequently used services.

Ubuntu's Uncomplicated Firewall (UFW) provides a user-friendly interface for managing iptables rules:

ufw allow 23/tcp

ufw reload

These commands create an exception for Telnet traffic and apply the changes immediately.

How Can User Management Improve Telnet in Linux Security?

Telnet in linux does not provide encryption, but proper user management can reduce exposure in limited or controlled environments. A key practice is creating dedicated accounts for Telnet sessions instead of using shared or root logins. This is done with the standard Linux command:

adduser telnetuser

The system then prompts for information such as full name, contact details, and other metadata stored in the user database. Strong password policies are essential for accounts accessible over a network. Using the command:

passwd telnetuser

administrators should enforce requirements such as a minimum length of 12–16 characters, inclusion of uppercase and lowercase letters, numbers, and symbols, while avoiding dictionary words or personal details. Passwords should also be rotated on a regular schedule. In multi-user environments, group-based access controls provide additional safeguards. For example:

groupadd telnetusers  

usermod -a -G telnetusers telnetuser

This ensures more centralized and consistent access management.

Comprehensive Command Syntax and Advanced Usage Patterns

The fundamental syntax structure for the linux telnet command provides flexibility for various connectivity scenarios and testing requirements:

telnet [options] [hostname/IP] [port]

The hostname/IP parameter accepts multiple formats to accommodate different networking environments and requirements. Hostname specification supports fully qualified domain names (FQDN) such as server.company.example.com, which undergo DNS resolution to determine the target IP address. This method provides convenience and readability but introduces potential points of failure if DNS services are unavailable or compromised.

Direct IP address specification, such as 192.168.1.100 for IPv4 or 2001:db8::1 for IPv6, bypasses DNS resolution entirely, providing more reliable connectivity testing and reducing dependency on external services.

The port parameter, while optional, enables testing of various services beyond the default Telnet daemon. Common port specifications include:

  • Port 22: SSH (Secure Shell) service testing

  • Port 25: SMTP (Simple Mail Transfer Protocol) mail server connectivity

  • Port 53: DNS (Domain Name System) service verification

  • Port 80: HTTP web server accessibility

  • Port 110: POP3 email retrieval service testing

  • Port 143: IMAP email server connectivity

  • Port 443: HTTPS secure web server testing

  • Port 993: IMAPS secure email service verification

  • Port 995: POP3S secure email retrieval testing

Advanced usage examples demonstrate the versatility of the telnet command in linux for network diagnostics:

telnet www.example.com 80

This command establishes a connection to a web server's HTTP port, after which you can manually craft HTTP requests to test server responsiveness and retrieve raw HTML content.

For mail server testing:

telnet mail.example.com 25

Once connected, you can issue SMTP commands to verify mail server configuration and test email delivery pathways.

How Can Telnet in Linux Be Used for Port Testing and Network Diagnostics?

One of the most practical uses of the telnet command in linux is systematic port connectivity testing and troubleshooting. This helps administrators, security professionals, and developers verify service availability and diagnose problems across networks.

The syntax is straightforward:

telnet target-system port-number

Outcomes vary. A blank screen confirms a completed TCP handshake, while banners or prompts reveal service details. Some services terminate immediately if they reject interactive connections. Failed attempts produce useful diagnostics:

1. “Connection refused” means no service is listening.

2. “Connection timed out” suggests firewall blocks or unreachable targets.

3. “Host unreachable” points to routing issues or invalid addresses.

Telnet can test common services across categories:

# Administrative ports

telnet server.example.com 22    # SSH

telnet server.example.com 23    # Telnet

telnet server.example.com 3389  # RDP


# Web services

telnet server.example.com 80    # HTTP

telnet server.example.com 443   # HTTPS

telnet server.example.com 8080  # Alt HTTP


# Databases

telnet database.example.com 3306   # MySQL

telnet database.example.com 5432   # PostgreSQL

telnet database.example.com 1433   # MS SQL

Detailed Practical Use Cases and Real-World Applications

Despite security limitations, the telnet command in linux continues to serve several important diagnostic and testing purposes in controlled environments and specific technical scenarios.

SMTP Mail Server Diagnostics and Testing

Email system administrators frequently use Telnet for comprehensive mail server testing and troubleshooting. This approach provides direct access to SMTP protocol interactions, enabling detailed analysis of mail server behavior and configuration validation.

Basic SMTP connection testing:

telnet mail.example.com 25

Upon successful connection, the mail server responds with a greeting banner containing version information and availability status. Advanced testing involves manual SMTP command execution:

EHLO client.example.com

MAIL FROM:<[email protected]>

RCPT TO:<[email protected]>

DATA

Subject: Test Message


This is a test message.
.
QUIT

This sequence tests the complete email delivery pathway, verifying server authentication requirements, relay permissions, and message processing capabilities.

Web Server Analysis and HTTP Protocol Testing

Web developers and system administrators utilize Telnet for low-level HTTP interaction and server behavior analysis. This approach provides insights into server configuration, response headers, and protocol compliance.

Basic HTTP GET request testing:

telnet www.example.com 80

After connection establishment, manually craft HTTP requests:

GET / HTTP/1.1

Host: www.example.com

User-Agent: Custom-Test-Client/1.0

Note the blank line following the headers, which signals request completion according to HTTP protocol specifications. The server responds with status codes, headers, and content that reveal configuration details and potential issues.

Advanced HTTP testing includes:

  • Custom header injection for testing server behavior

  • POST request simulation for form submission testing

  • Virtual host testing by varying the Host header

  • Keep-alive connection testing for performance analysis

Database Connectivity Verification

Database administrators often need to verify basic connectivity to database servers without installing full client software or exposing credentials through application logs.

Common database port testing:

# MySQL/MariaDB testing

telnet mysql.example.com 3306


# PostgreSQL testing  

telnet postgres.example.com 5432


# MongoDB testing

telnet mongo.example.com 27017


# Oracle database testing

telnet oracle.example.com 1521

While these connections cannot perform actual database operations, they confirm network accessibility, firewall configuration, and basic service availability.

Custom Application Protocol Development and Debugging

Software developers creating custom network applications with text-based protocols find Telnet invaluable for testing and debugging during development cycles.

For applications using simple request-response patterns, Telnet enables:

  • Manual command testing without custom client development

  • Protocol behavior verification under various conditions

  • Error handling validation through malformed input injection

  • Performance characteristics observation through timing analysis

Example custom protocol testing:

telnet application.example.com 8080

Then send custom commands specific to your application's protocol:

CONNECT user=admin session=12345

LIST RESOURCES

GET resource_id=67890

DISCONNECT

This approach provides immediate feedback on protocol implementation correctness and helps identify edge cases that might not be apparent through automated testing alone.

Comprehensive Security Risk Analysis and Threat Assessment

Understanding the complete spectrum of security vulnerabilities inherent in telnet in linux implementations is crucial for making informed decisions about when and how to use this protocol in modern environments.

Why Is the Lack of Encryption in Telnet in Linux So Dangerous?

Telnet’s most critical flaw is the absence of encryption, leaving all traffic exposed in plain text. Any attacker monitoring network activity can immediately capture usernames, passwords, authentication tokens, system commands, and configuration details. Even file contents, application data, and network topology revealed during sessions are vulnerable.

The ease of exploitation is striking: simple monitoring tools, available to anyone, can intercept and decode Telnet traffic without advanced skills. Risks increase further on wireless networks, where transmissions can be captured remotely without physical access, making Telnet one of the most insecure protocols still in use today.

Advanced Attack Vectors and Exploitation Techniques

1. Session Hijacking
Attackers can observe active Telnet sessions, steal credentials, and replace the legitimate user. The system cannot distinguish them, granting full access.

2. Man-in-the-Middle (MITM)
Positioned between client and server, attackers intercept and alter traffic in real time, injecting commands or taking full control unnoticed.

3. Credential Harvesting
Automated tools capture Telnet logins from network traffic, later used for lateral movement across systems.

4. Replay Attacks
Recorded authentication sequences can be reused to access systems, often paired with timing analysis to bypass detection.

Regulatory Compliance and Legal Implications

1. PCI DSS
Requires encryption for cardholder data. Using Telnet can lead to penalties or loss of processing rights.

2. HIPAA
Mandates encryption for protected health information. Healthcare systems using Telnet risk fines and sanctions.

3. GDPR
Demands technical safeguards like encrypted transmission. European organizations must replace Telnet to stay compliant.

4. SOX
Requires secure internal controls for financial reporting. Telnet use in financial systems violates compliance standards.

Superior Modern Alternatives and Migration Strategies

The evolution of network security has produced several sophisticated alternatives that address Telnet's fundamental weaknesses while providing enhanced functionality and security features.

SSH (Secure Shell) – The Definitive Replacement

SSH is the secure successor to Telnet, closing its vulnerabilities while offering broader functionality. It encrypts all communication with strong algorithms such as AES and ChaCha20, preventing intercepted data from being read. 

Authentication is more advanced, supporting public keys, certificates, multi-factor systems, and Kerberos instead of simple logins. 

Integrity is preserved through cryptographic hashing, ensuring commands and responses remain unaltered. 

Beyond security, SSH adds useful capabilities including port forwarding, secure file transfers with SCP and SFTP, and even X11 forwarding for graphical applications. These features make SSH the gold standard for remote administration in modern networks.

Netcat – The Swiss Army Knife of Network Tools

For network diagnostics and testing scenarios, netcat (nc) provides capabilities that far exceed those of the telnet command in linux while maintaining similar simplicity and flexibility.

Unlike Telnet’s TCP-only limitation, netcat supports both TCP and UDP protocols, allowing comprehensive network service testing and communication pathway verification.

It also offers enhanced port testing with more informative output, including detailed error messages and connection timing that simplify troubleshooting.

Netcat can operate as both client and server, enabling bidirectional communication for advanced testing and data transfers not possible with traditional Telnet.

Its consistent output and flexible options make it easy to integrate into automated testing scripts and monitoring systems.

cURL – Advanced Web Service Interaction

When working with web servers, APIs, or any URL-accessible resources, cURL provides capabilities that make manual HTTP crafting through the telnet command in linux seem primitive by comparison.

It supports a wide range of protocols including HTTP, HTTPS, FTP, FTPS, SFTP, and LDAP, offering seamless switching and a consistent interface.

Unlike Telnet, cURL automatically handles SSL/TLS, negotiates secure connections, validates certificates, and manages encryption without user input.

It also manages cookies, redirects, authentication, headers, and form submissions, eliminating the need for manual protocol construction.

For API testing, cURL supports GET, POST, PUT, DELETE, and more with JSON, XML, and other data formats.

Advanced Troubleshooting and Common Issues

Administrators often face recurring Telnet problems that require systematic checks.

Connection Refused may occur when no service listens on the port, firewalls block traffic, services are misconfigured, security policies like SELinux restrict access, or resources are exhausted. Troubleshooting includes testing from multiple sources, verifying service status, and checking firewall logs.

Timeouts usually signal network issues such as routing errors, misconfigured firewalls, congestion, DNS failures, or MTU mismatches causing fragmentation.

Authentication Failures often result from account lockouts, expired or disabled accounts, unmet password policies, insufficient permissions, or incorrect shell assignments that prevent session establishment.

What Security Measures Are Essential for Telnet in Linux Environments?

When circumstances absolutely require Telnet usage, implementing comprehensive security measures can reduce (though not eliminate) associated risks:

#1. Network Isolation
Restrict Telnet usage to isolated network segments with no internet connectivity and limited access to production systems.

#2. VPN Protection
Tunnel Telnet connections through VPN infrastructure to provide encryption at the network layer.

#3. Session Monitoring
Implement comprehensive logging and monitoring of all Telnet sessions, including command execution, file access, and administrative actions.

#4. Time Limitations
Establish maximum session durations and automatic termination policies to limit exposure windows.

#5. Access Controls
Implement strict role-based access controls and principle of least privilege for Telnet-accessible accounts.

#6. Regular Auditing
Conduct frequent security audits of systems using Telnet, including access log review and vulnerability assessments.

Conclusion and Future Considerations

This comprehensive examination of the telnet command in linux has explored its historical significance, technical implementation, security vulnerabilities, and modern alternatives. While Telnet played a crucial role in the development of network computing and continues to serve specific diagnostic purposes, its fundamental security flaws make it unsuitable for most contemporary applications.

Understanding Telnet remains valuable for educational purposes, legacy system maintenance, and historical context in network protocol evolution. However, its practical application should be limited to isolated, non-production environments where security risks can be adequately controlled and mitigated through compensating measures.

Blog