Install telnet for linux

How and Why to Use Linux to Install Telnet

Ransomware recovery test drive: This technical workshop is designed to take you behind the scenes and shows you how to adopt strategies to automate recovery, ensuring you’re ready to become a recovery hero. REQUEST YOUR LAB

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.

  • 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.

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:

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.

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.

Installing the telnet client and daemon

4. Verify that the telnet client version number with grep.

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

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.

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:

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

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.

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.

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.

Читайте также:  Install windows steam on linux

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.

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

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

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

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.

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.

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.

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.

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.

Читайте также:  Linux mint установка сетевого принтера

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

Connect to the mail server using Telnet

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

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

Depending on your mail server configuration, you will see many other available SMTP commands that the server supports.

3. Next, type mail from: [email protected] and press Enter to specify the sender’s email address. Replace [email protected] with your actual email address.

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

Specify the sender

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

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

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

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

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.

Hate ads? Want to support the writer? Get many of our tutorials packaged as an ATA Guidebook.

Источник

How to Install and Use Telnet on Linux Systems

Remote access to other operating system environments on an active network is not just a thing of the SSH (Secure Shell) protocol. Telnet achieves the same functionality through TCP/IP protocol.

Читайте также:  Linux pid фонового процесса

With Telnet, you not only get to establish successful remote connections but also troubleshoot and test the system services that define the remote computing environment.

For instance, we could check if a particular port is active/open/listening on the targeted remote system. It is worth noting that Telnet utilizes port 23 for its remote TCP connections.

Install Telnet in Linux

This article will walk us through the installation and usage of this ancient server administration protocol. Since Telnet is unencrypted, its recommended usage is for testing purposes only and in user-defined networks.

$ sudo apt-get install telnetd [On Debian, Ubuntu and Mint] $ sudo yum install telnetd [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a net-misc/netkit-telnetd [On Gentoo Linux] $ sudo pacman -S telnetd [On Arch Linux] $ sudo zypper install telnetd [On OpenSUSE]

Install Telnet in Linux

Check on its status to make sure it is up and running.

$ sudo systemctl status inetd

Check Telnet in Linux

Testing Remote Linux Connections via Telnet

To perform an unencrypted connection to remote host systems via Telnet, we first need to identify the IP address of the machine we are targeting.

Find Linux IP Address

Also, the targeted remote Linux machine should have Telnet installed on it as per the suggested installation commands discussed above.

$ sudo apt install telnetd -y

Also, check on the status of Telnet to make sure it is running on the remote machine too.

$ sudo systemctl status inetd

On the Telnet-powered server machine, we will adhere to the following syntax rule:

$ telnet [remote-system-ip-address]

The implementation of the above syntax rule will look like the following:

The above IP address belongs to the targeted machine. If you are using or have a firewall enabled on your remote/targeted Linux machine, you will need to allow traffic through port 23 since Telnet uses it for its network communication.

$ sudo ufw allow 23/tcp [On Ubuntu & Debian] $ sudo firewall-cmd --permanent --zone=public --add-port=23/tcp [On RHEL] $ sudo firewall-cmd --reload

We can now attempt to make a Telnet connection to a targeted/remote Linux machine.

Connect to Linux Using Telnet

An acceptable user login input will be followed by a password request which when we key in should give us managerial access to the remote Linux system. Once granted access, the interface should change to something like the following:

Telnet Remote Linux Login

From here, we can perform normal OS operations if needed.

Testing Open Ports on Linux via Telnet

Another interesting feature Telnet offers its users is its ability to detect an open or closed port on a targeted remote system via its IP address. This feature is useful in figuring out any vulnerabilities present on your system.

For instance, we can check if the above discussed remote system has port 80 open by executing the following command:

If the port is open, you will see an output like the following:

Check Linux Port Using Telnet

If the port is blocked, then expect the following outcome:

Telnet Unable to Connect to Remote Host

You can also test your mail server through the SMTP port 25:

With Telnet, you can make remote connections to other client computers with the same approach as SSH and additionally test any vulnerabilities on your system by troubleshooting if a suspicious port is listening/open or unintentionally closed.

Источник

Оцените статью
Adblock
detector