Telnet is a protocol that allows you to connect to remote computers (called hosts) over a TCP/IP network using a client-server protocol. To establish a connection, you must have a Telnet client installed on your computer. Once you have a Telnet client, you can use it to connect to any host on the Internet that supports the Telnet protocol. When you connect to a host, you will be prompted for a username and password. If you enter the correct credentials, you will be granted access to the host’s command-line interface. From there, you can issue commands to the host just as if you were sitting in front of it.
Telnet is an incredibly useful tool for remotely administering systems, and it is also widely used by developers for testing purposes. However, it should be noted that Telnet is an unencrypted protocol, which means that all data exchanged between the client and server is sent in plain text. As such, it is not recommended for use in applications where security is important.
In the following tutorial, you will learn how to install Telnet on a CentOS 9 Stream server or desktop workstation, along with some basic commands on connecting to a remote server using the command line terminal.
Warning About using Telnet
The tutorial will show you how to install Telnet for historical purposes and use it in local environments, and isolated networks. It is highly recommended not to use Telnet on an open network connection to the Internet because the data is sent over the connection, including sensitive information such as passwords and other confidential information that is not encrypted so the data can be easily intercepted by a hacker and misused. To safely connect to remote servers over public networks, you should always use SSH (Secure Shell).
Update CentOS Stream
First, update your system to ensure all existing packages are up to date. This will ensure no conflicts arise as best as possible during the installation.
sudo dnf upgrade --refresh -y
Install Telnet Server
CentOS 9 Stream come with the Telnet package available to install using the dnf package manager.
First, use the following command to install.
sudo dnf install telnet telnet-server -y
Next, enable the Telnet socket; the following command will activate it immediately.
sudo systemctl start telnet.socket
Do not enable Telnet on system boot, and this should only be used manually; when finished, disable it with the following command.
sudo systemctl disable telnet.socket
Once installed, check to ensure Telnet status is ok with the following command.
systemctl status telnet.socket
Connect Telnet Instance
Optional. Set Firewalld Rule
Firstly, if you have FirewallD installed to connect to your remote running Telnet, you will need to set up an allow rule. By default, Telnet runs on port 23.
Setting up an allow rule in FirewallD can be done in several ways. It is highly recommended to give the IP of the connecting server only if at significantly worse the subnet. Do not leave port 23 open to everything, which will lead to brute force attempts.
First, add a new dedicated zone for Telnet firewalld policy:
sudo firewall-cmd --permanent --new-zone=telnet
Next, specify the allowed IP addresses permitted to access the Telnet server.
sudo firewall-cmd --permanent --zone=telnet --add-source=1.2.3.4
Replace 1.2.3.4 with the IP address that will be added to the allow list.
Once you have finished adding the IP addresses, open the port of the Telnet. By default, this is TCP port 23.
sudo firewall-cmd --permanent --zone=telnet --add-port=23/tcp
Note, that you can change the default port in your configuration file if you change the firewall port open rule above to the new value.
After running those commands, reload the firewall to implement the new rules:
sudo firewall-cmd --reload
Example output if successful:
success
Test Connection
Now that you have set up a FirewallD rule to connect to your remote server using Telnet, use the following Telnet command and the IP address of the system you are connecting to, which also requires Telnet to be activated.
telnet 192.168.50.234
In the tutorial which has CentOS 9 Stream, the default machine is connected to a remote Ubuntu 22.04 LTS system. Note, that you will need the login information handy depending on the setup as the above image shows.
How to Update/Upgrade Telnet
Given that Telnet was installed with the DNF package manager, you would use the same commands you would with any system update using the command line terminal as the example below.
sudo dnf update --refresh
If an update is available for Telnet, you will see it in the printout the list of updates available to install.
How to Remove (Uninstall) Telnet
Remove Telnet from your operating system, all you need to do is use the following command:
sudo dnf autoremove telnet telnet-server -y
Comments and Conclusion
Overall, in today’s world, the most secure form of communication of this nature is to use SSH instead of Telnet. However, If you’re looking for a way to remotely connect to other computers, Telnet is the protocol for you. By using a client-server protocol to establish a connection to Transmission Control Protocol port number 23, you can use Telnet to access remote hosts all over the world.