---
title: "How and Why to Use Linux to Install Telnet"
description: "Learn the how and why behind using Linux to install telnet and when this older technology may still become useful!"
canonical: "https://adamtheautomator.com/linux-to-install-telnet/"
---

# How and Why to Use Linux to Install Telnet

> Learn the how and why behind using Linux to install telnet and when this older technology may still become useful!

Source: https://adamtheautomator.com/linux-to-install-telnet/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How and Why to Use Linux to Install Telnet](https://adamtheautomator.com/wp-content/uploads/2022/08/How-and-Why-to-Use-Linux-to-Install-Telnet.jpg)

# How and Why to Use Linux to Install Telnet

[![](https://secure.gravatar.com/avatar/2788bb1a3f735603f81eca51d68daec56a9d97e805a10268fb2c20afcc76b81b?s=192&d=mm&r=g)Nicholas Xuan Nguyen](https://adamtheautomator.com/author/nicholas-xuan-nguyen/)6 September 20226 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Linux](/tag/linux/)[Telnet](/tag/telnet/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Using Linux to Install Telnet](#using-linux-to-install-telnet)
*   [Opening the Local Firewall to Allow Telnet Access](#opening-the-local-firewall-to-allow-telnet-access)
*   [Checking for an Open Port Using Telnet](#checking-for-an-open-port-using-telnet)
*   [Checking Port Connectivity to an SMTP Server](#checking-port-connectivity-to-an-smtp-server)
*   [Conclusion](#conclusion)

Do you need to remotely access and test your devices? Telnet may be just what you need. Although not as popular as it once was, Telnet is still a helpful tool for many system administrators.

In this article, you will learn how to use Linux to install Telnet,, how to use it to connect to remote devices, and testing connectivity to see if it’s working properly.

## Prerequisites

This tutorial will be a hands-on demonstration. If you’d like to follow along, be sure you have the following.

*   A Linux system. This tutorial uses Ubuntu 20.04, but any modern Linux system should work.

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

*   An account with sudo privileges. This tutorial uses a root account, but it would be more appropriate to use a non-root account with sudo privileges for security reasons.

Related:[How to Create User on Ubuntu Linux in Multiple Ways](https://adamtheautomator.com/create-user-on-ubuntu/)

*   An SMTP mail server. Any SMTP mail server should work.

Related:[How to Build an IIS SMTP Relay Server](https://adamtheautomator.com/iis-smtp-relay/)

## Using Linux to Install Telnet

The telnet client is not installed by default on most Linux distributions. You must install it before you can use it.

To install the telnet client on Ubuntu Linux, follow these steps:

1\. Open a terminal window.

2\. Update the apt package list to make sure you have the latest package versions:

> _Prepend the sudo command if you use a non-root account._

```bash
apt update -y
```

![Update the apt package list](https://adamtheautomator.com/wp-content/uploads/2022/08/image-591.png)

Update the apt package list

3\. Run the below command to install the telnet client and daemon. You will not need the daemon in this tutorial, but it comes in the same package as the client.

```bash
apt install telnetd -y
```

![Installing the telnet client and daemon](https://adamtheautomator.com/wp-content/uploads/2022/08/image-592.png)

Installing the telnet client and daemon

4\. Verify that the telnet client version number with [grep](https://adamtheautomator.com/powershell-grep/).

Related:[How to Use PowerShell Grep (Select-String)](https://adamtheautomator.com/powershell-grep/)

```bash
dpkg -l | grep telnet
```

If the telnet client is present on the system, you will see output similar to the following.

![Checking the Telnet version number](https://adamtheautomator.com/wp-content/uploads/2022/08/image-593.png)

Checking the Telnet version number

5\. Run the grep command below to check if the telnet command is in the path environment variable. This command returns the below output, indicating that the telnet command is available.

Related:[How To Wrangle Ubuntu Environment Variables](https://adamtheautomator.com/ubuntu-environment-variables/)

```bash
which telnet
```

![Checking if the telnet command is in the system path](https://adamtheautomator.com/wp-content/uploads/2022/08/image-594.png)

Checking if the telnet command is in the system path

## Opening the Local Firewall to Allow Telnet Access

The telnet client uses port 23 by default. If you have a firewall configured on your system, you must open port 23 to allow telnet traffic.

To open port 23 with UFW on Ubuntu, follow these steps:

Related:[How To Set Up the UFW Firewall on Linux](https://adamtheautomator.com/ufw-firewall/)

1\. Open a terminal window.

2\. Check the status of the firewall to make sure it’s active.

```bash
ufw status
```

You will see output similar to the following if the firewall is active. If the status is not active, you can skip this section since you don’t need to allow the port on a firewall that isn’t running.

![Checking the status of the firewall.](https://adamtheautomator.com/wp-content/uploads/2022/08/image-595.png)

Checking the status of the firewall.

3\. To allow traffic on port 23, type the following command. This command opens port 23 for tcp traffic. By default, telnet uses a TCP port to establish a connection.

```bash
ufw allow 23/tcp
```

![Open port 23 for TCP traffic](https://adamtheautomator.com/wp-content/uploads/2022/08/image-596.png)

Open port 23 for TCP traffic

4\. Verify that the port is open by typing the following command to display a list of firewall rules. As you can see in the output, tcp traffic on port 23 is now allowed from anywhere.

```bash
ufw status numbered
```

![Verify that port 23 is open](https://adamtheautomator.com/wp-content/uploads/2022/08/image-597.png)

Verify that port 23 is open

## Checking for an Open Port Using Telnet

Now that you’ve installed the telnet client, you can start testing it out. In this section, you will use telnet to check if a port is open on a remote system.

Telnet provides a bidirectional interactive text-oriented communications facility using a virtual terminal connection. When you telnet to a remote machine, you are running the telnet program on your local machine and connecting to the remote machine’s telnet daemon.

The daemon allows you to log in and run commands on the remote machine as if sitting at the console.

> _Note: Telnet is an insecure protocol because the information exchange happens in plain text and is not encrypted, including passwords. Anyone who can sniff network traffic can capture sensitive information._
> 
> _For this reason, it is generally advisable to use SSH instead of telnet whenever possible._

But there are still some uses for telnet—for example, troubleshooting network connectivity issues by checking for open ports. Also, to connect to legacy systems that do not support SSH.

1\. Suppose you want to check if the 22 port is open on a remote machine before you can SSH into it. Run the below command to telnet to the remote host’s port 22.

```bash
telnet 147.182.182.104 25
```

If port 22 is open, you will see an output similar to the below screenshot. The Connected to 147.182.182.104 output indicates that you have successfully established a connection to the remote machine.

![Checking Open Port Using Telnet](https://adamtheautomator.com/wp-content/uploads/2022/08/image-598.png)

Checking Open Port Using Telnet

If the port is closed, you will see a Trying… message followed by a connection timed out error, as shown below. This output indicates that the port is closed or no daemon is listening on the remote host.

![Port 25 is closed](https://adamtheautomator.com/wp-content/uploads/2022/08/image-599.png)

Port 25 is closed

2\. To exit the telnet session, press Ctrl+\], type quit at the telnet> prompt, and press Enter.

![Exit the telnet session](https://adamtheautomator.com/wp-content/uploads/2022/08/image-600.png)

Exit the telnet session

3\. Now, SSH into the remote machine securely. Replace 147.182.182.104 with the IP address of the remote machine.

Related:[Leverage SSH and PowerShell to Securely Transfer Files Now](https://adamtheautomator.com/powershell-ssh/)

```bash
ssh root@147.182.182.104
```

Enter your password at the prompt and press Enter. You are now logged into the remote machine using SSH.

![ SSH into the remote machine securely.](https://adamtheautomator.com/wp-content/uploads/2022/08/image-601.png)

SSH into the remote machine securely.

## Checking Port Connectivity to an SMTP Server

Finding the root cause of an issue on a mail server can be difficult. There are many configuration files and components involved in the mail delivery process. To troubleshoot mail server issues, you must check each component’s status in the mail delivery chain.

The most basic step is to use telnet to connect to each component and check if it is running correctly. In this section, you will learn how to use telnet to check the status of an SMTP mail server via port 2525.

Related:[How to Build an IIS SMTP Relay Server](https://adamtheautomator.com/iis-smtp-relay/)

> _In most cases, the standard ports for SMTP servers are 25, 465, 587, and 2525. You need to know its listening port to connect to the mail server. This example uses port 2525. Contact your mail server administrator to get this information._

1\. To connect to the mail server using telnet, type the following command at the terminal. Replace smtp.example.com and 2525 with your SMTP mail server’s correct FQDN and port number.

```bash
telnet smtp.example.com 2525
```

You will see an output similar to the following. The first line of output shows the IP address of the mail server (35.187… in this example). The second line indicates that the connection to the server was successful. The last line is the status code and message from the server.

In this case, code 220 indicates that the server is ready to receive mail.

![Connect to the mail server using Telnet](https://adamtheautomator.com/wp-content/uploads/2022/08/image-602.png)

Connect to the mail server using Telnet

2\. Next, issue some commands to the server to check its status. Type EHLO and press Enter.

```bash
EHLO
```

> _EHLO is short for HELO and HELLO, a command to identify the SMTP client to the server. This command opens the conversation from the client to the server. The server responds with a list of commands that it supports._

You will see an output similar to the following. The first line of the server response is the status code (250) and message. The remaining lines are a list of SMTP commands that the server supports.

![Open the conversation between the client and the server](https://adamtheautomator.com/wp-content/uploads/2022/08/image-603.png)

Open the conversation between the client and the server

> _Depending on your mail server configuration, you will see many [other available SMTP commands](https://www.geeksforgeeks.org/smtp-commands/) that the server supports._

3\. Next, type mail from: your@email.com and press Enter to specify the sender’s email address. Replace your@email.com with your actual email address.

```bash
mail from: your@email.com
```

The server responds with a status code 250 and an OK message, indicating the server is running correctly.

![Specify the sender's email address.](https://adamtheautomator.com/wp-content/uploads/2022/08/image-604.png)

Specify the sender’s email address.

4\. Now, type rcpt to: recipient@example.com and press Enter to specify the recipient’s email address. Replace recipient@example.com with the email address of the recipient. This command tells the SMTP server that you want to send an email to that recipient address.

```bash
rcpt to: recipient@example.com
```

The server responds with a status code 250 and an OK message, indicating that the recipient’s email address is valid and the server is running correctly.

![Specify the recipient's email address.](https://adamtheautomator.com/wp-content/uploads/2022/08/image-605.png)

Specify the recipient’s email address.

5\. Finally, quit the telnet session by typing quit and pressing Enter.

```bash
quit
```

The server responds with a status code 221 and a goodbye message, which indicates that the server is running correctly.

![Quit the telnet session](https://adamtheautomator.com/wp-content/uploads/2022/08/image-606.png)

Quit the telnet session

## Conclusion

In this article, you have learned how to install Telnet on Linux. You have also learned how to use Telnet to check for open ports, check the status of an SMTP server, and perform a simple conversation with an SMTP server. These skills will be helpful when you are troubleshooting server connectivity.

Due to its nature, you should not have Telnet running on your production servers. Telnet is ancient, so to speak, and is now equivalent to a security risk. Telnet does not offer any encryption or authentication. Use Telnet for testing and troubleshooting only.

Telnet has better and more secure alternatives, such as SSH for managing servers remotely or `netcat` for testing network connectivity. But, having Telnet under your belt is still a good idea, as it can be handy in certain situations.

Related:[How To Use Netcat and Level-Up Your Networking Skills!](https://adamtheautomator.com/how-to-use-netcat/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Flinux-to-install-telnet%2F&text=How%20and%20Why%20to%20Use%20Linux%20to%20Install%20Telnet)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Flinux-to-install-telnet%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Flinux-to-install-telnet%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Practical-Linux-Unix-Tee-Commands-for-the-Linux-Admin.jpg)

### [Master Unix tee Commands for Real-World Linux Admin Tasks](/unix-tee/)

Simplify Linux output management and streamline your workflow with the “Unix tee” command. This tutorial guides you through its practical applications.

![](https://adamtheautomator.com/wp-content/uploads/2024/03/openldap-4.jpg)

### [How to Install and Configure an OpenLDAP Ubuntu Server](/openldap/)

Unlock the power of OpenLDAP on Ubuntu for centralized user authentication, seamless access control management, and enhanced directory services!

![](https://adamtheautomator.com/wp-content/uploads/2024/03/pipe-command-in-linux-1.jpg)

### [Unleashing the Power of the Pipe Command in Linux](/pipe-command-in-linux/)

Unlock the prowess of the pipe command in Linux to streamline tasks, boost productivity, and simplify complex operations effortlessly!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
