The tutorial explains about how to install telnet server on CentOS 7 / RHEL 7 . We will also keep SELINUX on enforcing mode and use the firewalld rules.
About Telnet
Telnet is a network protocol used on the Internet or local area networks to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection .
Recommended: We always recommend to use SSH because it communicates in encrypted way. Whereas telnet do not communicates in encrypted way.
Telnet Port Number
By default telnet server listens on port number 23/tcp .
To know more about telnet, read this Wikipedia link.
IMPORTANT NOTE:
By default root is not able to login via telnet. Hence, use other system user.
Diagram :
Description about our Lab :
Operating System : CentOS 7
IP Address : 192.168.56.101 (This is also telnet server ip address)
Arch : x86_64
Install Telnet Server
Installing telnet-server is quite easy, Simply run the below command on your system terminal.
yum install telnet-server
Start/Stop/Restart Telnet service
To start the telnet service on CentOS 7 / RHEL 7 use the command –
systemctl start telnet.socket
To stop the telnet service on CentOS 7 / RHEL 7 use the command –
systemctl stop telnet.socket
To restart the telnet service on CentOS 7 / RHEL 7 use the command –
systemctl restart telnet.socket
To get status of the telnet service on CentOS 7 / RHEL 7 use the command –
systemctl status telnet.socket
Check listening port by telnet
To check listening port 23 by telnet on system, use ss command –
ss -tnlp|grep 23
Below given is reference from our system.It shows the port number 23 is listening.
[root@localhost ~]# ss -tnlp|grep 23 LISTEN 0 128 :::23 :::* users:(("systemd",1,53)) [root@localhost ~]#
Allow telnet from firewalld
We strictly recommend to use the telnet-server inside LAN only. It should not be accessible from Public network.
In below section, we are allowing source subnet 192.168.56.0/24 to access the telnet service by using firewalld command.
(Replace the 192.168.56.0/24 with your LAN network subnet or client ip address)
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.56.0/24" service name="telnet" log prefix="telnet" level="info" limit value="1/m" accept'
Access telnet-server
To access telnet-server, use the following command syntax
Syntax: Replace telnet-server-ip-address with ip address of telnet server.
telnet telnet-server-ip-address
It will prompt for giving username and password. Use system username other than root.
sharad@linuxworld:~/Desktop$ telnet 192.168.56.101 Trying 192.168.56.101... telnet: Unable to connect to remote host: No route to host sharad@linuxworld:~/Desktop$ telnet 192.168.56.101 Trying 192.168.56.101... Connected to 192.168.56.101. Escape character is '^]'. Kernel 3.10.0-123.el7.x86_64 on an x86_64 localhost login: test Password: Last login: Sat Dec 6 08:01:10 from ::ffff:192.168.56.1 [test@localhost ~]$
Sujata says
Thank you! Very helpful
LX_telnet says
Thank you for this info. I see that telnet socket becomes inactive very soon on my newly installed RHEL7.2 host . How do I change the setting?
Sharad Chhetri says
Hi Bage,
To properly find the reason, you should check the logs. The location of log is /var/log.
Regards
Sharad
armando says
excelente
Alyssa says
Thanks for this… Can I ask how will change the telnet port from 23 to other ports like 7777?
invi77 says
it says ‘telnet-server’ not found when i fire that yum install telnet-server command
chasil says
You can also do this:
cd /home
wget http://busybox.net/downloads/binaries/latest/busybox-x86_64
ln -s busybox-x86_64 telnet
ln -s busybox-x86_64 login
ln -s busybox-x86_64 telnetd
Then configure your socket and service files with busybox.
sharad chhetri says
Thank you for sharing tip Chasil,
I prefer to do not rename busybox, it helps for no conflict when we install actual telnet package or no confusion to other user.
Overall the tip is nice. Keep sharing the good tips with Linux and Open Source World.
Really appreciate.
Best Regards
Sharad
wdog says
thanks!!!
sharad chhetri says
Welcome friend,