Setting up telnet on Linux involves using your package manager to install the client and configuring the service to start automatically. This guide will show you exactly how to install telnet on linux step by step, covering both the client and server components for major distributions.
Understanding Telnet And Its Use Cases
Telnet is a network protocol that lets you connect to remote computers over a TCP/IP network. It’s been around since the early days of the internet and remains useful for testing network services and accessing legacy systems.
However, telnet sends all data—including passwords—in plain text. That’s why modern systems prefer SSH for secure remote access. But for troubleshooting, testing port connectivity, or managing older equipment, telnet still has its place.
You might need telnet to check if a specific port is open on a server, test SMTP or HTTP services manually, or connect to network devices like routers and switches that don’t support SSH.
Telnet Client Vs Telnet Server
There are two parts to telnet: the client and the server. The client is the program you use to connect to remote systems. The server runs on the machine you want to access remotely.
Most Linux distributions don’t install telnet by default. You’ll need to install the client, the server, or both depending on your needs.
For security reasons, only install the telnet server if you absolutely need it. Consider using SSH instead whenever possible.
Prerequisites For Installing Telnet On Linux
Before you start, make sure you have:
- A Linux system (Ubuntu, Debian, CentOS, RHEL, Fedora, or similar)
- Sudo or root access to install packages
- An active internet connection to download packages
- Basic familiarity with the terminal
That’s all you need. The installation process is straightforward and takes just a few minutes.
How To Install Telnet On Linux
Now let’s get into the main process. The exact commands depend on your Linux distribution, but the general approach is the same.
Installing Telnet On Ubuntu And Debian
Ubuntu and Debian use the APT package manager. Open your terminal and run:
- Update your package list:
sudo apt update - Install the telnet client:
sudo apt install telnet -y - If you need the server:
sudo apt install telnetd -y - Verify the installation:
telnet --version
That’s it. The telnet client is now ready to use. You can test it by connecting to a remote host.
For the server, after installing telnetd, the service starts automatically. You can check its status with sudo systemctl status telnetd.
Installing Telnet On CentOS And RHEL 7/8
CentOS and RHEL use YUM or DNF package managers. Here’s how:
- For CentOS 7:
sudo yum install telnet telnet-server -y - For CentOS 8 or RHEL 8:
sudo dnf install telnet telnet-server -y - Enable the telnet service:
sudo systemctl enable telnet.socket - Start the service:
sudo systemctl start telnet.socket - Check status:
sudo systemctl status telnet.socket
On CentOS/RHEL, the telnet server uses systemd socket activation. This means the service only starts when a connection is received, which is more efficient.
Installing Telnet On Fedora
Fedora uses DNF. The process is similar to CentOS 8:
- Install both client and server:
sudo dnf install telnet telnet-server -y - Enable the socket:
sudo systemctl enable telnet.socket - Start the socket:
sudo systemctl start telnet.socket - Verify:
sudo systemctl status telnet.socket
Fedora’s default firewall might block telnet. You’ll need to allow port 23 through the firewall if you want external connections.
Installing Telnet On OpenSUSE
OpenSUSE uses Zypper. Run these commands:
sudo zypper refreshsudo zypper install telnet telnetd- Start the service:
sudo systemctl start telnetd - Enable at boot:
sudo systemctl enable telnetd
OpenSUSE might require you to configure the firewall manually. We’ll cover that in the next section.
Configuring Telnet Server After Installation
Once you’ve installed the telnet server, you need to configure it properly for security and functionality.
Starting And Enabling The Telnet Service
On systemd-based distributions, use these commands:
- Start the service:
sudo systemctl start telnetdorsudo systemctl start telnet.socket - Enable at boot:
sudo systemctl enable telnetdorsudo systemctl enable telnet.socket - Check status:
sudo systemctl status telnetd
If the service doesn’t start, check the logs with journalctl -u telnetd for error messages.
Configuring Firewall For Telnet
Telnet uses port 23. You need to allow this port through your firewall.
For UFW (Ubuntu/Debian):
sudo ufw allow 23/tcpsudo ufw reload
For firewalld (CentOS/RHEL/Fedora):
sudo firewall-cmd --add-port=23/tcp --permanentsudo firewall-cmd --reload
For iptables:
sudo iptables -A INPUT -p tcp --dport 23 -j ACCEPT- Save the rules:
sudo iptables-save
Always restrict telnet access to trusted networks if possible. Use firewall rules to limit which IPs can connect.
Configuring Telnet For Remote Access
By default, telnet might only listen on localhost. To allow remote connections, edit the telnet configuration file.
On most systems, the configuration is in /etc/xinetd.d/telnet or /etc/inetd.conf. Look for a line like:
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
Make sure the disable option is set to no if using xinetd. Then restart the service.
For security, consider using TCP wrappers (/etc/hosts.allow and /etc/hosts.deny) to control access.
Testing Your Telnet Installation
After installation, test that everything works correctly.
Testing Telnet Client Locally
Connect to localhost to verify the server is running:
telnet localhost
You should see a login prompt. Enter your username and password to test authentication.
If you get “Connection refused,” the server isn’t running or the port is blocked.
Testing Telnet To A Remote Server
To connect to a remote system, use:
telnet [remote_ip_address] [port]
For example, to test port 80 on a web server:
telnet 192.168.1.100 80
If the port is open, you’ll see a blank screen or a service banner. Press Ctrl+] then type “quit” to exit.
Common Telnet Connection Errors
Here are typical issues and their solutions:
- Connection refused: The service isn’t running or the port is blocked by firewall
- Name or service not known: The hostname is incorrect or DNS is not working
- Connection timed out: Network issues or firewall blocking the connection
- Login incorrect: Wrong username or password, or the account doesn’t have shell access
Double-check your firewall rules and service status if you encounter errors.
Security Considerations When Using Telnet
Telnet is inherently insecure. Here’s what you need to know.
Why Telnet Is Considered Insecure
Telnet transmits everything in plain text. This includes:
- Usernames and passwords
- Commands you type
- Output from the remote system
- Any files you transfer
Anyone on the network can capture this data using tools like Wireshark. That’s why SSH is the preferred choice for remote access.
Best Practices For Secure Telnet Usage
If you must use telnet, follow these guidelines:
- Only use telnet on trusted, isolated networks
- Never use telnet over the internet
- Use strong passwords for telnet accounts
- Restrict telnet access via firewall rules
- Disable telnet when not in use
- Consider using SSH tunnels to encrypt telnet traffic
- Monitor telnet logs for unauthorized access
Remember, telnet is a tool for specific situations, not a general-purpose remote access solution.
Uninstalling Telnet When No Longer Needed
When you’re done with telnet, remove it to reduce security risks.
On Ubuntu/Debian:
sudo apt remove telnet telnetd -ysudo apt autoremove -y
On CentOS/RHEL:
sudo yum remove telnet telnet-server -y
On Fedora:
sudo dnf remove telnet telnet-server -y
Also remove firewall rules for port 23 if they’re no longer needed.
Troubleshooting Common Telnet Issues
Even with proper installation, you might run into problems. Here’s how to fix them.
Telnet Command Not Found
If you get “command not found,” the telnet client isn’t installed. Run the installation command for your distribution again.
Make sure you installed the client package, not just the server.
Connection Refused Error
This usually means the telnet server isn’t running or the port is blocked. Check:
- Service status:
sudo systemctl status telnetd - Firewall rules:
sudo ufw statusorsudo firewall-cmd --list-all - Port listening:
sudo netstat -tulpn | grep :23
If the service is running but still refusing connections, check the configuration files for errors.
Slow Telnet Connections
Telnet can feel sluggish due to DNS lookups. To speed it up, disable DNS resolution:
telnet -n [host] [port]
Or add the remote host’s IP to your /etc/hosts file.
Telnet Session Freezes Or Hangs
This often happens when the connection drops unexpectedly. Press Ctrl+] to get the telnet prompt, then type “close” to exit.
You can also set a timeout in your telnet client configuration.
Alternatives To Telnet For Remote Access
While telnet is useful, consider these more secure alternatives.
SSH (Secure Shell)
SSH encrypts all traffic, including authentication. It’s the standard for remote access on Linux.
Install SSH: sudo apt install openssh-server (Ubuntu) or sudo yum install openssh-server (CentOS)
Connect: ssh user@remote_host
Netcat For Port Testing
Netcat (nc) is great for testing ports without the security risks of telnet.
Install: sudo apt install netcat
Test port: nc -zv remote_host 80
Nmap For Network Scanning
Nmap can check multiple ports at once and identify services running on them.
Install: sudo apt install nmap
Scan: nmap -p 23 remote_host
Frequently Asked Questions
Is Telnet Installed By Default On Linux?
No, most modern Linux distributions do not install telnet by default due to security concerns. You need to install it manually using your package manager.
Can I Install Telnet Without Internet Access?
Yes, you can download the telnet package files from a system with internet and transfer them via USB or local network. Use apt-get download telnet on Ubuntu or yumdownloader telnet on CentOS to get the .deb or .rpm files.
How Do I Check If Telnet Is Already Installed?
Run which telnet or telnet --version in the terminal. If you get a path or version number, telnet is installed. If you see “command not found,” it’s not installed.
What Port Does Telnet Use?
Telnet uses TCP port 23 by default. You can specify a different port when connecting with telnet host port.
Is It Safe To Use Telnet For Testing Purposes?
Yes, for testing on local networks or isolated environments, telnet is fine. Just avoid using it over public networks or the internet where traffic can be intercepted.
Conclusion
Installing telnet on Linux is a simple process that takes just a few commands. Whether you need the client for testing or the server for legacy system access, the steps are straightforward across all major distributions.
Remember the security implications of using telnet. Always prefer SSH for remote access, and only use telnet when absolutely necessary. Keep your firewall rules tight and disable telnet when you’re done.
With this guide, you now know how to install telnet on linux, configure it properly, and troubleshoot common issues. Use this knowledge responsibly and your Linux system will serve you well.