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 to Transmission Control Protocol port number 23
In the following tutorial, you will learn how to install Telnet on Ubuntu 20.04 and 21.04.
Table of Contents
The tutorial will show you how to install Telnet for historical purposes and use in local environments, 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).
- Recommended OS: Ubuntu 20.04 – optional (Ubuntu 21.04 and Linux Mint 20)
- User account: A user account with sudo or root access.
Install Telnet Server Ubuntu 20.04
The Ubuntu 20.04 repository has Telnet available by default.
First, use the following command to install:
sudo apt install telnetd -y
Once installed, check to make sure Telnet status is operating ok with the following:
sudo systemctl status inetd
Connect to your Telnet server on Ubuntu 20.04
Set UFW Rule
Firstly, to connect to your remote system running Telnet, you will need to set up an allow rule. By default, Telnet runs on port 23.
To set up an allow rule in UFW can be done in several ways. It is highly recommended to give the IP of the connecting server only if at very worse the subnet. Do not leave port 23 open to everything, and this will lead to brute force attempts.
The rule for single IP:
sudo ufw allow from 22.214.171.124 to any port 23
Allow from subnet:
sudo ufw allow from 126.96.36.199/24 to any port 23
Now that you have set up a UFW rule so you can connect to your remote server using Telnet, use the following (telnet) command:
Uninstall Telnet from Ubuntu 20.04
To remove Telnet off your Ubuntu 20.04 operating system, all you need to do is use the following command:
sudo apt autoremove telnetd --purge
This will fully remove Telnet and traces. To re-install, following the tutorial from the start.
Comments and Conclusion
In the tutorial, you have learned how to install, set up a firewall rule, and connect to a remote server using Telnet. Overall, in today’s world, the most secure form of communication of this nature is to use SSH instead of Telnet. However, development environments that run on isolated local networks Telnet can be more useful. Still, you would never run Telnet in a public network these days, and it would open your server up to a very high risk in doing so.