Tutorial

Telnet Command Usage in Linux/Unix

Published on August 3, 2022
author

Pankaj

Telnet Command Usage in Linux/Unix

What is Telnet ?

Telnet is an old network protocol that is used to connect to remote systems over a TCP/IP network. It connects to servers and network equipment over port 23. Let’s take a look at Telnet command usage.

Disclaimer

  1. Telnet is not a secure protocol and is thus NOT RECOMMENDED!. This is because data sent over the protocol is unencrypted and can be intercepted by hackers.
  2. Instead of using telnet, a more preferred protocol to use is SSH which is encrypted and more secure

Let’s see how you can install and use the telnet protocol.

Installing Telnet

In this section, we will walk you through the process of installing telnet in RPM and DEB systems.

Installation of Telnet in CentOS 7 / RHEL 7

To begin the installation process on the server, run the command

# yum install telnet telnet-server -y

Sample Output Install Telnet Telnet Server Next, Start and enable the telnet service by issuing the command below

 
# systemctl start telnet.socket
# systemctl enable telnet.socket

Sample Output Start And Enable Telnet Next, allow port 23 which is the native port that telnet uses on the firewall.

# firewall-cmd --permanent --add-port=23/tcp

Finally, reload the firewall for the rule to take effect.

# firewall-cmd --reload

Sample Output Allow Port 23 Over Firewall To verify the status of telnet run

# systemctl status telnet.socket

Sample Output Check Status Of Telnet In CentOS 7 Telnet protocol is now ready for use. Next, we are going to create a login user.

Creating a login user

In this example, we will create a login user for logging in using the telnet protocol.

# adduser telnetuser

Create a password for the user.

# passwd telnetuser

Specify the password and confirm. To use telnet command to log in to a server, use the syntax below.

$ telnet server-IP address

For example

$ telnet 38.76.11.19

In the black console, specify the username and password. Telnet Ip Address To login using putty, enter the server’s IP address and click on the ‘Telnet’ radio button as shown. Telnet Putty Configuration Finally, click on the ‘Open’ button. On the console screen, provide the username and password of the user Logging In To Centos Via Telnet In Putty

Installation of Telnet in Ubuntu 18.04

To install telnet protocol in Ubuntu 18.04 execute:

$ sudo apt install telnetd -y

Sample Output Install Telnet On Ubuntu To check whether telnet service is running, execute the command.

$ systemctl status inetd

Sample Output Systemctl Status Inetd Next, we need to open port 23 in ufw firewall.

$ ufw allow 23/tcp

Sample Output Allow Port 23 Over Ufw Firewall Finally, reload the firewall to effect the changes.

$ ufw reload

Reload ufw Firewall Telnet has been successfully installed and ready for use. Like in the previous example in CentOS 7, you need to create a login user and log in using the same syntax.

Using telnet to check for open ports

Telnet can also be used to check if a specific port is open on a server. To do so, use the syntax below.

$ telnet server-IP port

For example, to check if port 22 is open on a server, run

$ telnet 38.76.11.19  22

Sample Output Telnet To Test Open Ports

Summary

This tutorial is an educational guide that shows you how to use telnet protocol. We HIGHLY DISCOURAGE the use of telnet due to the high-security risks it poses due to lack of encryption. SSH is the recommended protocol when connecting to remote systems. The data sent over SSH is encrypted and kept safe from hackers.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Pankaj

author

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
April 7, 2020

a very simple, yet complete/easy to understand/easy to use guide about telnet. thanks!

- David Zambrano

    JournalDev
    DigitalOcean Employee
    DigitalOcean Employee badge
    April 29, 2019

    why we use TELNET then??instead of using SSH where we can use TELNET?? i want to know plz help me…

    - rishav

      Try DigitalOcean for free

      Click below to sign up and get $200 of credit to try our products over 60 days!

      Sign up

      Join the Tech Talk
      Success! Thank you! Please check your email for further details.

      Please complete your information!

      Featured on Community

      Get our biweekly newsletter

      Sign up for Infrastructure as a Newsletter.

      Hollie's Hub for Good

      Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

      Become a contributor

      Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

      Welcome to the developer cloud

      DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

      Learn more