Telnet is a network protocol that allows you to connect to remote computers over TCP/IP networks. It is often used for network troubleshooting and testing. This guide will show you how to install Telnet client and server on Linux systems using simple methods.
⚠️ Security Warning: Telnet transmits data, including passwords, in plain text. It is not secure and should only be used in trusted networks or for testing purposes. For secure remote access, consider using SSH.
Installing Telnet Client and Server on Ubuntu/Debian Systems
Step 1: Update Your System
It's a good practice to update your package list before installing new software.
sudo apt update && sudo apt upgrade -y
Step 2: Install Telnet Client
The Telnet client allows you to connect to remote Telnet servers.
sudo apt install telnet -y
Step 3: Install Telnet Server (If Needed)
To allow other systems to connect to your machine via Telnet, install the Telnet server.
sudo apt install xinetd telnetd -y
Step 4: Configure Telnet Server
- Create a Telnet configuration file for
xinetd
:
sudo nano /etc/xinetd.d/telnet
- Add the following content to the file:
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
- Save and close the file (press
Ctrl + X
, thenY
, andEnter
). - Restart the
xinetd
service:
sudo systemctl restart xinetd
- Enable the service to start on boot:
sudo systemctl enable xinetd
Step 5: Adjust Firewall Settings (If Applicable)
If you have a firewall enabled (like UFW), allow traffic on port 23
, which is the default Telnet port.
sudo ufw allow 23/tcp
Check the firewall status:
sudo ufw status
Step 6: Test Telnet Connection
- From the same machine or a remote client with Telnet installed, connect to the Telnet server:
telnet server_ip_address
- You should see a login prompt. Enter your username and password to log in.
Installing Telnet Client and Server on CentOS/RHEL/AlmaLinux Systems
Step 1: Update Your System
Update your package list before proceeding.
# For CentOS 7/8 and newer
sudo yum update -y
Step 2: Install Telnet Client
Install the Telnet client using the package manager.
sudo yum install telnet -y
Step 3: Install Telnet Server (If Needed)
Install the Telnet server package.
sudo yum install telnet-server xinetd -y
Step 4: Configure Telnet Server
- Edit the Telnet server configuration file:
sudo nano /etc/xinetd.d/telnet
- Locate the line
disable = yes
and change it todisable = no
. - Save and close the file.
- Start and enable the
xinetd
service:
sudo systemctl start xinetd
sudo systemctl enable xinetd
Step 5: Adjust Firewall Settings (If Applicable)
If you have firewalld
enabled, allow traffic on port 23
:
sudo firewall-cmd --permanent --add-port=23/tcp
sudo firewall-cmd --reload
Step 6: Test Telnet Connection
- From the same machine or a remote client with Telnet installed, connect to the Telnet server:
telnet server_ip_address
- You should see a login prompt. Enter your username and password to log in.
Using Telnet for Network Troubleshooting
Telnet can be used to test connectivity to TCP ports on remote servers.
Example: Testing if a Port is Open
# Check if port 80 is open on example.com
telnet example.com 80
If the connection is successful, the terminal will clear, or you may see a response from the server. If it fails, you'll receive a connection error.
Example: Sending HTTP Request via Telnet
- Connect to the server on port 80:
telnet example.com 80
- Type an HTTP request and press
Enter
twice:
GET / HTTP/1.1
Host: example.com
- You should receive an HTTP response from the server.
Security Considerations
- Telnet transmits data in plain text, making it insecure for transmitting sensitive information.
- Use Telnet only in secure, trusted networks or for testing purposes.
- For secure remote access, use SSH instead of Telnet.
- Consider disabling or uninstalling Telnet services when not in use.
Uninstalling Telnet
Ubuntu/Debian Systems
# Remove Telnet client
sudo apt remove telnet -y
# Remove Telnet server
sudo apt remove telnetd xinetd -y
CentOS/RHEL/AlmaLinux Systems
# Remove Telnet client
sudo yum remove telnet -y
# Remove Telnet server
sudo yum remove telnet-server xinetd -y
Conclusion
You have successfully installed Telnet on your Linux server for network troubleshooting. Remember to use Telnet cautiously due to its lack of encryption. For secure communication, it's recommended to use SSH.