How to Install and Use Telnet on Linux Systems

In Linux, the telnet is a popular utility that creates a remote connection with a system over a TCP/IP network. Due to the unencrypted communication between the remote system, telnet was soon replaced with a better alternative SSH (Secure Shell) protocol.

Telnet can perform a few things that can be very helpful for Linux network administrators, like testing the open port over the remote system for troubleshooting, which is not possible in SSH protocol.

Ensure the communication is not publicly exposed; otherwise, telnet unencrypted communication between remote and client can be disclosed and intercepted by an attacker.

The default port is 23 used by the telnet to establish the connection between the remote and client system over the TCP/IP network.

Install Telnet in Linux

Telnet is an old and popular utility available in all Linux repositories by default. Depending on your Linux distribution, you can use the selective command to install the telnet.

Also, do make sure to install the telnet on both the remote and client system to establish a successful connection.

On Debian/Ubuntu/PopOS

$ sudo apt install telnetd -y

On RHEL/CentOS/Fedora

$ sudo yum install telnetd

On Gentoo Linux

$ sudo emerge -a net-misc/netkit-telnetd

On Arch/Manjaro

$ sudo pacman -Sy telnetd 

On OpenSUSE

$ sudo zypper install telnetd

After the installation is complete, make sure to check the status of the telnet daemon using the below command in your system.

$ sudo systemctl status inetd

Below is the behavior of this command.

Checking telnet status in Linux
Checking telnet status in Linux

Above, you can see the active status in my system. If it is disabled in your system, use the below command to start the telnet daemon in your system.

$ sudo systemctl start inetd

Connecting Remote Linux System via Telnet

To perform an unencrypted connection between remote and client using telnet, first, you need to find out the local/public IP address of the remote/destination system using the below command.

$ ifconfig

Below is the behavior of this command.

Checking Remote System IP address
Checking Remote System IP address

Also, make sure to install telnet on the remote/destination system and check the daemon’s status. If it is not active, start the daemon as mentioned one step earlier in this guide.

Below is the syntax for testing the connection between remote and client via telnet.

$ telnet [remote-system-ip-address]

The real-life implementation of the above code looks like the following.

$ telnet 192.168.0.107

The above command successfully set up the connection between remote and client. In a case, if you were using any firewall like ufw to prevent unauthorized access, then do not forget to allow port 23 used by telnet on the remote/destination system, as shown below.

$ sudo ufw allow 23/tcp #Allow the 23 Port
$ sudo ufw reload #Restart the UFW

Below is the behavior of this command.

Allowing telnet port 23
Allowing telnet port 23

Once you have done, you can reattempt and check the telnet connection to a targeted/remote Linux machine.

$ telnet 192.168.0.107

Below is the behavior of this command.

Connecting to Remote Linux System via Telnet
Connecting to Remote Linux System via Telnet

While connecting to the remote system, you will be asked to enter the remote system username and password to access the remote system, as shown above.

After authenticating with the correct username and password, you are now allowed to execute all of the commands permitted by that specific authenticated user in that remote system, as shown below.

Telnet Remote Linux Login
Telnet Remote Linux Login

Testing Open Ports on Remote Linux via Telnet

The telnet can also perform minor network administration tasks, such as testing open and closed ports of the remote/destination system in an unencrypted connection.

Below is the syntax used to check the port on the remote system for the open or close status.

$ telnet [remote-system-ip-address] [remote-system-port]

To perform the test, specify that specific port you need to check on the remote system for the status as shown below.

$ telnet 192.168.0.107 80

Below is the behavior of this command.

Check the port status on the remote system
Check the port status on the remote system via telnet

If the remote system specified port is closed, then the below result will occur in the output.

Testing closed port in the remote system via telnet
Testing closed port in the remote system via telnet

Same as telnet, you use an alternative SSH protocol to set up the connection between remote and client with the AES encryption, which encrypts all the communication between remote and client.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments