Tutorials  /  Linux Basics

Telnet Command in Linux/Unix

Ccentron Redaktion · January 2024 ·5 min read ·Linux Basics, Tutorial

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 the telnet command in Linux.

VM

Try it yourself: cloud servers from €3.12/month

ccloud³ VMs from German data centers – deployed in seconds, billed by the hour, with a €200 starting credit for new accounts. Launch a server →

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

Installation of Telnet in CentOS 7 / RHEL 7

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

Console
# yum install telnet telnet-server -y

Next, start and enable the telnet service by issuing the command below:

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

Next, allow port 23 which is the native port that telnet uses on the firewall.

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

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

# firewall-cmd --reload

Console
# firewall-cmd --reload

To verify the status of telnet run

Console
# systemctl status telnet.socket

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.

Console
# adduser telnetuser
Create a password for the user.
# passwd telnetuser

Create a password for the user.

Console
# passwd telnetuser

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

Console
$ telnet server-IP address
For example
$ telnet 38.76.11.19

For example

Console
$ telnet 38.76.11.19

In the black console, specify the username and password.

To login using putty, enter the server’s IP address and click on the ‘Telnet’ radio button.

Finally, click on the ‘Open’ button. On the console screen, provide the username and password of the user.

Installation of Telnet in Ubuntu 18.04

To install telnet protocol in Ubuntu 18.04 execute:

Console
$ sudo apt install telnetd -y

To check whether telnet service is running, execute the command.

Console
$ systemctl status inetd

Next, we need to open port 23 in ufw firewall.

Console
$ ufw allow 23/tcp

Finally, reload the firewall to effect the changes.

Console
$ ufw reload

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.

Console
$ telnet server-IP port

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

Console
$ telnet 38.76.11.19 22

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. Register now in the ccenter to access more security guides and best practices for secure server management.

%3Cscript%20type%3D%22application%2Fld%2Bjson%22%3E%0D%0A%7B%0D%0A%20%20%22%40context%22%3A%20%22https%3A%2F%2Fschema.org%22%2C%0D%0A%20%20%22%40graph%22%3A%20%5B%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%22%40id%22%3A%20%22%23article%22%2C%0D%0A%20%20%20%20%20%20%22%40type%22%3A%20%22Article%22%2C%0D%0A%20%20%20%20%20%20%22headline%22%3A%20%22Telnet%20Command%20in%20Linux%2FUnix%22%2C%0D%0A%20%20%20%20%20%20%22name%22%3A%20%22Telnet%20Command%20in%20Linux%2FUnix%22%2C%0D%0A%20%20%20%20%20%20%22description%22%3A%20%22This%20article%20explains%20what%20Telnet%20is%2C%20why%20the%20protocol%20is%20not%20recommended%20for%20secure%20connections%2C%20how%20to%20install%20Telnet%20on%20CentOS%2C%20RHEL%2C%20and%20Ubuntu%2C%20and%20how%20to%20use%20Telnet%20to%20connect%20to%20remote%20systems%20or%20check%20open%20ports.%22%2C%0D%0A%20%20%20%20%20%20%22inLanguage%22%3A%20%22en-US%22%2C%0D%0A%20%20%20%20%20%20%22about%22%3A%20%5B%0D%0A%20%20%20%20%20%20%20%20%22Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Linux%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Unix%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Network%20protocol%22%2C%0D%0A%20%20%20%20%20%20%20%20%22TCP%2FIP%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Port%2023%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Remote%20connection%22%2C%0D%0A%20%20%20%20%20%20%20%20%22SSH%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Firewall%22%2C%0D%0A%20%20%20%20%20%20%20%20%22CentOS%22%2C%0D%0A%20%20%20%20%20%20%20%20%22RHEL%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Ubuntu%22%2C%0D%0A%20%20%20%20%20%20%20%20%22UFW%22%2C%0D%0A%20%20%20%20%20%20%20%20%22firewall-cmd%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Putty%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Port%20checking%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Server%20security%22%0D%0A%20%20%20%20%20%20%5D%2C%0D%0A%20%20%20%20%20%20%22keywords%22%3A%20%5B%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20command%20Linux%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20Unix%22%2C%0D%0A%20%20%20%20%20%20%20%20%22install%20Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20CentOS%207%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20RHEL%207%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20Ubuntu%2018.04%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20port%2023%22%2C%0D%0A%20%20%20%20%20%20%20%20%22check%20open%20ports%20with%20Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%22telnet%20server-IP%20port%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Telnet%20security%22%2C%0D%0A%20%20%20%20%20%20%20%20%22SSH%20instead%20of%20Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%22firewall-cmd%20Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%22UFW%20port%2023%22%2C%0D%0A%20%20%20%20%20%20%20%20%22systemctl%20telnet.socket%22%2C%0D%0A%20%20%20%20%20%20%20%20%22Putty%20Telnet%22%0D%0A%20%20%20%20%20%20%5D%2C%0D%0A%20%20%20%20%20%20%22articleSection%22%3A%20%22Linux%22%2C%0D%0A%20%20%20%20%20%20%22publisher%22%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22Organization%22%2C%0D%0A%20%20%20%20%20%20%20%20%22name%22%3A%20%22centron%22%2C%0D%0A%20%20%20%20%20%20%20%20%22url%22%3A%20%22https%3A%2F%2Fwww.centron.de%2F%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%22mainEntityOfPage%22%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22WebPage%22%2C%0D%0A%20%20%20%20%20%20%20%20%22%40id%22%3A%20%22https%3A%2F%2Fwww.centron.de%2Fen%2F%22%0D%0A%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%22mentions%22%3A%20%5B%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22An%20older%20network%20protocol%20used%20to%20connect%20to%20remote%20systems%20over%20a%20TCP%2FIP%20network%2C%20typically%20using%20port%2023.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22TCP%2FIP%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20protocol%20suite%20used%20for%20network%20communication%20and%20for%20establishing%20connections%20between%20systems.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Port%2023%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22The%20default%20network%20port%20used%20by%20the%20Telnet%20protocol.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22SSH%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22An%20encrypted%20and%20more%20secure%20protocol%20for%20connecting%20to%20remote%20systems%2C%20recommended%20as%20an%20alternative%20to%20Telnet.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22SoftwareApplication%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Telnet%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22applicationCategory%22%3A%20%22NetworkApplication%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22operatingSystem%22%3A%20%22Linux%2C%20Unix%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20network%20service%20and%20command-line%20tool%20used%20to%20establish%20unencrypted%20remote%20connections%20and%20test%20reachable%20network%20ports.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22SoftwareApplication%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Putty%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22applicationCategory%22%3A%20%22NetworkApplication%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22operatingSystem%22%3A%20%22Windows%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20client%20application%20that%20can%20be%20used%20to%20establish%20Telnet%20or%20SSH%20connections%20to%20remote%20servers.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22telnet.socket%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20systemd%20socket%20unit%20used%20to%20start%2C%20enable%2C%20and%20monitor%20the%20Telnet%20service%20on%20Linux%20systems.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22firewall-cmd%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20command-line%20tool%20for%20managing%20firewall%20rules%20on%20systems%20using%20firewalld%2C%20for%20example%20to%20open%20port%2023%20for%20Telnet.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22UFW%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20simplified%20firewall%20management%20tool%20for%20Ubuntu%20systems%20that%20can%20be%20used%20to%20allow%20TCP%20port%2023%20for%20Telnet.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22CentOS%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20Linux%20distribution%20on%20which%20Telnet%20can%20be%20installed%20and%20configured%20using%20yum%20and%20related%20system%20tools.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22RHEL%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22Red%20Hat%20Enterprise%20Linux%2C%20an%20enterprise%20Linux%20distribution%20on%20which%20Telnet%20can%20be%20installed%20and%20managed%20using%20yum.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Ubuntu%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20Linux%20distribution%20on%20which%20Telnet%20can%20be%20installed%20with%20apt%20and%20configured%20with%20systemctl%20and%20UFW.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Port%20checking%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22The%20process%20of%20checking%20whether%20a%20specific%20network%20port%20is%20reachable%20or%20open%20on%20a%20server%2C%20for%20example%20with%20telnet%20server-IP%20port.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Remote%20connection%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22A%20network%20connection%20to%20a%20remote%20system%2C%20which%20can%20be%20established%20insecurely%20with%20Telnet%20or%20securely%20with%20SSH.%22%0D%0A%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%22%40type%22%3A%20%22DefinedTerm%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22Server%20security%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%22description%22%3A%20%22The%20practice%20of%20protecting%20server%20systems%20with%20secure%20protocols%2C%20encrypted%20connections%2C%20and%20appropriate%20firewall%20rules.%22%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%5D%0D%0A%20%20%20%20%7D%0D%0A%20%20%5D%0D%0A%7D%0D%0A%3C%2Fscript%3E

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren