Here are the steps to install and configure Telnet on both Ubuntu/Debian and CentOS/RHEL systems. You can copy-and-paste each block directly into your terminal.

To check if you have telnet package already installed on your system, use :

rpm -qa | grep telnet  

Output will be :

telnet-server-0.17-59.el7.x86_64

telnet-0.17-59.el7.x86_64

1. Install Telnet client

Ubuntu / Debian

sudo apt update
sudo apt install -y telnet

CentOS / RHEL

sudo yum install -y telnet

This gives you the telnet command for testing remote TCP services.

 

2. (Optional) Install Telnet server

 

Warning: Telnet transmits credentials in plain text. For secure remote shell access, use SSH. Only install a Telnet server if you have a specific requirement and restrict access tightly.

 

Ubuntu / Debian

sudo apt install -y telnetd xinetd

 

CentOS / RHEL

sudo yum install -y telnet-server xinetd

Installing telnet packages using single command on RHEL/CentOS: 

Telnet client and server in one go on a RHEL/CentOS system:

(install it using yum)

yum install telnet-server telnet 
or
sudo yum install telnet telnet-server

3. Enable and configure the Telnet service

 

  1. Create or edit /etc/xinetd.d/telnet so it contains:

service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}

  1. Restrict access (optional but strongly recommended):

    Add to /etc/hosts.allow:

in.telnetd: 192.0.2.0/24, 203.0.113.5

And deny all others in /etc/hosts.deny:

in.telnetd: ALL

  1. If using a firewall, open port 23:

    Ubuntu (ufw)

sudo ufw allow 23/tcp

 

CentOS (firewalld)

sudo firewall-cmd --permanent --add-port=23/tcp
sudo firewall-cmd --reload

 

  1. Enable and start xinetd so it listens for Telnet connections:

sudo systemctl enable xinetd
sudo systemctl start xinetd
  1. Verify that the server is listening on port 23:

sudo ss -tln | grep :23

Configuring/enabling telnet

 

1. Add the service to firewalld.

 

The built-in firewalld blocks Telnet to port 23 by default because the protocol is not considered secure. Please make sure that the port is open or if a non-default port is being used, that the port associated with Telnet is open for telnet traffic to pass through.

# firewall-cmd --add-service=telnet --zone=public

 

Run the rule again with the “–permanent” flag for it to persist across firewalld restarts.

# firewall-cmd --add-service=telnet --zone=public --permanent

 

2. Add the service to selinux.

 

You will have to also add the service to SELinux. This is required only in the case where SELinux is enabled on the system.

# semanage port -a -t telnetd_port_t -p tcp 

 

3. Enable and start the telnet service.

 

Start the service using the systemctl command.

# systemctl start telnet.socket

 

Enable the telnet service to start at boot.

# systemctl enable telnet.socket

 

4. Verify

 

Once you are done with the configuration, verify if the telnet to a server works.

KB Last updated: June 15, 2025 11:30 AM US Eastern Time

War diese Antwort hilfreich? 676 Benutzer fanden dies hilfreich (677 Stimmen)