How to Install Telnet on Ubuntu 22.04 or 20.04


Telnet is a protocol that allows users to connect to remote servers and devices over a network. It is a simple and widely-used method for managing servers and network devices, such as routers and switches. When incorporated into your Ubuntu desktop or server, telnet can benefit you by allowing you to access and manage network devices remotely, troubleshoot connectivity issues, and test network services. It is handy when you need to access a remote device or server but do not have physical access to it or if you have a headless server without a GUI.

Here are some of the features and benefits of using Telnet on Ubuntu:

  • Remote access: Telnet allows users to remotely access and manage network devices, servers, and other equipment. This is useful for administrators who need to manage and maintain a network from a remote location.
  • Troubleshooting: Telnet can troubleshoot connectivity issues by allowing users to test network services and connectivity to remote devices.
  • Scripting: Telnet can be used in scripts to automate tasks such as logging into remote devices and running commands.
  • Lightweight: Telnet is a lightweight protocol requiring minimal resources, making it ideal for low-spec or older systems.
  • Simplicity: Telnet is a simple and easy-to-use protocol, making it accessible to users of all skill levels.
  • Versatility: Telnet can be used on various platforms, including Windows, Linux, and macOS, making it a versatile protocol for managing and accessing remote devices.

However, it is also important to consider the risks associated with using Telnet:

  • Security: Telnet is not a secure protocol as it sends data in plain text, including login credentials. This makes it vulnerable to eavesdropping and can put sensitive information at risk.
  • Authentication: Telnet does not provide encryption or authentication, making it susceptible to man-in-the-middle attacks.
  • Deprecation: Telnet is an older protocol and is being replaced by more secure alternatives such as SSH.

In summary, Telnet can be a useful tool for managing and accessing remote devices, but weighing the benefits against the security risks associated with its use is important. Alternatives such as SSH should be considered for sensitive information. This article will provide a quick guide on installing Telnet on Ubuntu 22.04 or 20.04 LTS systems, as well as some examples of using Telnet commands.

Step 1: Update Ubuntu

Before installing Telnet, ensure your Ubuntu system is fully updated by running the following command in the terminal.

sudo apt update && sudo apt upgrade

This command will check for updates and upgrade the existing packages to their latest versions. It is an excellent practice to keep your system updated to ensure the smooth running of Telnet and other installed packages.

Step 2: Install Telnet

Telnet is included in the standard repository of Ubuntu, which makes the installation process relatively simple. To install Telnet on your Ubuntu system, run the following command in the terminal.

sudo apt install telnetd telnet

Once installed, check to ensure the Telnet status is okay with the following command.

systemctl status inetd

Example output:

If the Telnet service is not active, run the following command to start it immediately.

sudo systemctl start inetd

Step 3: Using Telnet (Command Examples)

With Telnet now installed and running on your Ubuntu system, the following are examples of using Telnet via the command line.

Connect to a specific host on a specific port.

telnet [hostname or IP address] [port]

Example:

telnet example.com 23

Connect to a specific host on a specific port with a specified timeout.

telnet [hostname or IP address] [port] [timeout in seconds]

Example:

telnet example.com 80 20

Connect to a specific host on a specific port with a specified timeout and a number of attempts.

telnet [hostname or IP address] [port] [timeout in seconds] [attempts]

Example:

telnet example.com 80 20 3

After running the commands, you may be prompted to enter your credentials and follow additional instructions in the terminal to complete the task. This is a standard process when making changes to the firewall rules. If you plan on using Telnet frequently on sensitive networks, it is recommended to follow step 4 to secure Telnet as much as possible with the UFW firewall. This will help to protect your system from unauthorized access and potential security threats.

See also
How to Install Thunderbird on Fedora Linux

Step 4: Secure Telnet with UFW Firewall

Securing Telnet on Ubuntu using ufw firewall can help to protect against unauthorized access and potential security threats. Here are the steps to secure Telnet on Ubuntu with ufw firewall:

Before configuring the UFW firewall to secure Telnet on Ubuntu, it is important first to check the status of the firewall. This can be done by running the following command in the terminal.

sudo ufw status

This command will provide information on the current status of the UFW firewall and any existing rules. It’s worth noting that UFW is pre-installed on all Ubuntu systems, so it should be on your system.

If the UFW firewall is not currently enabled on your Ubuntu system, you can enable it by running the following command in the terminal.

sudo ufw enable

This command will activate the firewall and begin enforcing the rules that have been set. It’s important to have the firewall enabled to secure Telnet and protect your system from unauthorized access and potential security threats.

After enabling UFW, the next step is configuring the firewall’s basic rules. This includes denying all incoming and outgoing connections by default. You can set these rules by running the following commands in the terminal.

sudo ufw default deny incoming
sudo ufw default allow outgoing

It’s important to note that these rules may already be set by default, but if not, it is advisable to set them. These rules will block all incoming connections and allow outgoing connections by default. This will provide an additional layer of security to protect your system from unauthorized access and potential security threats.

To enable Telnet connections through the UFW firewall, you can use the following command in the terminal.

sudo ufw allow telnet

To block Telnet connections through the UFW firewall, you can use the following command in the terminal.

sudo ufw deny telnet

This command will add a firewall rule blocking incoming Telnet connections. This will prevent any unauthorized access to your system using Telnet. This command helps avoid potential security threats and secure Telnet on your Ubuntu system.

Here are some examples of how to use ufw firewall to secure Telnet on Ubuntu.

To allow Telnet connections on port 23, use the command.

sudo ufw allow 23/tcp

To block Telnet connections on port 23, use the command.

sudo ufw deny 23/tcp

To allow Telnet connections from a specific IP address, use the command.

sudo ufw allow from 192.168.1.10 to any port 23

To block Telnet connections from a specific IP address, use the command.

sudo ufw deny from 192.168.1.10 to any port 23

To allow Telnet connections from a specific IP range, use the command.

sudo ufw allow from 192.168.1.0/24 to any port 23

It’s worth noting that Telnet is an insecure protocol, and SSH is recommended instead for secure remote access.

Additional Commands & Tips

Update Telnet

Keeping Telnet up-to-date on your Ubuntu system is easy. You can use the standard apt update command, which can be done by running the following command in the terminal.

sudo apt update && sudo apt upgrade

This command will check for any available updates for Telnet and its dependencies, and if any updates are found, they will be downloaded and installed. It is worth noting that Telnet is a relatively stable and rarely updated protocol, so it may not be necessary to check for updates constantly.

Remove (Uninstall) Telnet

To remove Telnet from your Ubuntu system, you can use the following command in the terminal:

sudo apt autoremove telnet telnetd

This command will remove the Telnet package and all its dependencies. Keep in mind that this action is permanent, and you will not be able to undo it. Before proceeding to remove it, it is also advisable to check if Telnet is not being used anymore by any of your applications or services.

See also
Solved: How to List All Users on a Linux System

Conclusion

Telnet is a protocol that allows users to access and manage devices over a TCP network remotely. Although Telnet can be a convenient tool, it is important to know its security risks as it is considered an insecure protocol. Telnet sends data, including login credentials, in plaintext, making it vulnerable to eavesdropping and other malicious activities. SSH is a more secure alternative for remote access. To further secure Telnet, it is recommended to use a firewall to block unnecessary incoming connections, implement strong authentication, and keep your system up to date with the latest security patches. It is essential to be mindful of the potential risks associated with Telnet and take appropriate measures to protect your systems and data.

Leave a Comment

Share to...