Telnet serves as a command line interface (CLI) tool that allows logging in and communication with a system through a TCP/IP network. Users can issue commands on a remote machine as Telnet users can log into a machine over a TCP/IP network with the use of Telnet addresses (e.g. telnet://user@hostname).
All users can type the login commands on the client machine and will grant access. Today, most people prefer to use SSH (Secure Shell) for remote access due to security issues in Telnet. Even with all the shortcomings posed by security risks, Telnet still serves the purpose in the following cases: testing open network ports, troubleshooting almost any network problem, and gaining access to very old legacy systems.
What is Telnet?
Telnet is an application protocol or older network protocol that Telnet enables the remote access to another machine with the use of telnet client, to connect to and execute commands on a remote machine that's hosting a telnet server. The telnet client will establish a connection with the server. The client will then become a virtual terminal- allowing you to interact with the remote host. It does not encrypt data, making it vulnerable to man-in-the-middle attacks. Despite its security flaws, it remains relevant for:
- It's legacy system administration
- Network troubleshooting (e.g., testing open ports)
- It is Basic remote access where security is not a concern.
The basic syntax of the Telnet command in Linux is:
telnet [hostname or IP address] [port]
- hostname or IP address → The remote server’s domain name or IP address you want to connect to.
- port → (Optional) The port number on which the Telnet service is running (default is port 23).
How to Install Telnet in Linux
To install the Telnet command in Linux, use the appropriate package manager:
Install Telnet on Ubuntu/Debian
To install Telnet on Ubuntu or Debian-based systems, run:
sudo apt update
sudo apt install telnet
To verify the installation, check the version:
telnet --version
Install Telnet on CentOS/RHEL
For CentOS and RHEL, use:
sudo yum install telnet
Confirm installation by checking the installed package:
rpm -q telnet
Install Telnet on Fedora
To install Telnet on Fedora, use:
sudo dnf install telnet
Basic Telnet Command Usage
In Linux, the Telnet command permits users to link with other servers through the web on Telnet port 23, which is also common for network connectivity tests, port checking, and remote admin. Below are some common Telnet commands showcasing the ease of use.
Syntax:
telnet <hostname or IP address> [port]
Example 1: Connecting to a Remote Server
To establish a connection with a remote system using Telnet on Linux Ubuntu or Telnet Linux CentOS, use:
telnet 192.168.1.1 # This command will attempt to access the device at the specified IP address
connection with a remote system using TelnetExample 2: Checking an Open Port
To check if port 80 (HTTP) is open on a website:
telnet example.com 80
If the connection is successful, the Telnet command Linux confirms the port is open. Otherwise, it indicates that the port is closed or blocked by a firewall.
To check if port open or notExample 3: Logging into a Remote System
When Telnet login is enabled on a remote server, you can connect and authenticate with valid credentials
telnet user@remote-host
- Enter the username and password when prompted.
- If login is successful, you can execute commands remotely.
Example 4: Creating a Login User for Telnet
To add a new user for Telnet login:
sudo adduser telnetuser
sudo passwd telnetuser
This creates a Telnet user named telnetuser
with a secure password.
Example 5: Download Web Page to File Using Telnet
You can use Telnet Linux commands to retrieve a webpage:
telnet example.com 80
GET / HTTP/1.1
Host: example.com
Download Web pageSecurity Risks of Using Telnet
The Telnet command in Linux operates over Telnet port 23 so they transmitting data in plain text which makes it vulnerable to various threats like:
- Password sniffing due to the lack of encryption. Due to no encryption attacker can do the Password sniffing
- Weak Firewall Rules via Unauthorized Access
- Man-in-the-middle attacks, compromising data security
How to Check Telnet Status
To verify if Telnet command in Linux is installed, run:
which telnet
If installed, it will return the path; otherwise, install Telnet Linux Ubuntu using:
sudo apt-get install telnet -y # For Ubuntu/Debian
sudo yum install telnet -y # For CentOS/RHEL
To check if Telnet port 23 is open, execute:
netstat -tulnp | grep :23
If Telnet is not active, start it with:
sudo systemctl start telnet
For persistent activation on boot, enable it:
sudo systemctl enable telnet
Firewall Configuration for Telnet in Linux
To enable Telnet command in Linux, you need to open Telnet port 23 in your firewall settings. This ensures that your system can accept Telnet connections.
For UFW (Ubuntu/Debian-based systems)
If using Ubuntu 18.04 or other Debian-based distributions, execute the following commands to open port 23:\
sudo ufw allow 23/tcp
sudo ufw reload
For Firewalld (CentOS/RHEL-based systems)
On CentOS or RHEL, use firewalld to open Telnet port 23:
sudo firewall-cmd --add-port=23/tcp --permanent
sudo firewall-cmd --reload
Note: Since Telnet Linux does not use encryption, consider using SSH vs Telnet for a more secure alternative.
Telnet vs SSH: Key Differences in Linux
Both protocols of Telnet and SSH in Linux accomplish the same task of remote access, however, they differ in a lot of aspects. Unlike Telnet, which is an old protocol, transmitting information openly, SSH (Secure Shell) system provides an encrypted line of communication, making remote system access much safer. Telnet's drawback is that it is an outdated protocol, using plain text for data transfer.
Feature | Telnet | SSH |
---|
Security | In this there is no encryption which means data sent in plain text | It is Encrypted so that there is secure data transmission) |
Default Port | 23 | 22 |
Authentication | Plain text which cause user credentials exposed | Secure authentication (Supports key-based login) |
Data Integrity | No (Prone to data interception and modification) | Yes (Ensures data is intact and unaltered) |
Usage | Legacy systems, network troubleshooting | Secure remote access and system administration |
Note: For more details refer the article Difference between SSH and Telnet
How to Disable Telnet in Linux
Since Telnet is insecure, disabling it is highly recommended to prevent unauthorized access and security breaches.
1. Disable Telnet on Linux
Stop the Telnet service immediately and disable Telnet from starting at boot using the below command
sudo systemctl stop telnet
sudo systemctl disable telnet
2. Block Telnet Port 23 Using Firewall
To prevent Telnet connections via port 23, use the UFW (Uncomplicated Firewall). Deny traffic on port 23 (Telnet port) and reload firewall rules to apply changes
sudo ufw deny 23/tcp
sudo ufw reload
Also Read:
Conclusion
Without a doubt, Telnet is a fundamental utility for a variety of network testing and even functioning with older systems, however, with it comes a new slew of security concerns. For direct access to newer systems, SSH is a undisputed necessity. When utilizing Telnet where it is required, make sure to implement firewall measures in conjunction with strong authentication to limit risks. Always ensure secure communication by disabling Telnet when not in use.
telnet command in linux- FAQs
How to use Telnet command in Linux?
To use the Telnet command in Linux, install it first using:
- Ubuntu/Debian:
sudo apt-get install telnet
- CentOS/RHEL:
sudo yum install telnet
Then, connect to a remote server using:
telnet <hostname or IP> <port>
What is a Telnet command?
The Telnet command in Linux is used for remote access, network troubleshooting, and port checking. It operates on port 23 and lacks encryption, making SSH a secure alternative.
How do I login to Telnet?
After connecting to a Telnet server, enter your Telnet login credentials:
telnet <server-IP>
If the server requires authentication, it will prompt for a username and password. Use key-based authentication for secure login in SSH.
Telnet command not found in Linux?
If the "telnet command not found" error appears, it means Telnet is not installed. Install it using:
- Ubuntu/Debian:
sudo apt-get install telnet
- CentOS/RHEL:
sudo yum install telnet
Then verify installation with:
telnet -V
How to check Telnet port on Linux?
To check if a port is open using Telnet, use:
telnet <IP/hostname> <port>
telnet example.com 80 # For example, to check if port 80 is open:
Similar Reads
talk command in linux In Linux, there are commands like write/wall which are used to communicate with other users especially by system administrators to send a short message to all logged-in users. There is one more command talk which is like an instant messenger service that enables two users to chat. In this article, w
3 min read
Netstat command in Linux The netstat command is like a special tool in Linux that helps you understand and check things about how your computer connects to the internet. It can tell you about the connections your computer is making, the paths it uses to send information, and even some technical details like how many packets
7 min read
Linux Commands Linux commands are essential for controlling and managing the system through the terminal. This terminal is similar to the command prompt in Windows. Itâs important to note that Linux/Unix commands are case-sensitive. These commands are used for tasks like file handling, process management, user adm
15+ min read
Linux Commands Cheat Sheet Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
13 min read
uname command in Linux with Examples Linux, renowned for its open-source flexibility and powerful performance, offers a range of commands that reveal the inner workings of your system. Among these, the 'uname' command stands out as a versatile tool that provides key details about your Linux machine. Here, we will learn the basics of th
4 min read
username Command in Linux With Examples Linux as an operating system holds the capabilities of handling multiple users each with a username and a display name (Full Name). So it is important to keep a check on the users and their related information in order to maintain the integrity and security of the system. Whenever a user is added it
4 min read