Thursday 8 October 2015

Install Telnet Server on CentOS 7 / RHEL 7

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 :
telnet server

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 firewall

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 ~]$
 

How configure Telnet client on Window 7

Open command prompt and run telnet command
windowclient-telnet
Error
 'telnet' is not recognized as an internal or external command, operable program or batch file.
windowclient-unrecognized-telnet
You will get error because Window 7 does not turn on telnet client service automatic. We need to start it manually.
Open control panel and click on program.
windowclient-control-pannel-program
click on turn windows features on or off
windowclient-program-window
Scroll down and check mark on Telnet client and click on OK
windowclient-checked-telnet
Now you can run telnet command. Login form normal user
windowclient-logged-in-normal-user
logout from normal user and try to login from root
windowclient-exit-from-normal-user
By default root user is not allowed to login through the terminal session
windowclient-root-fail
To allow root user Go on server system and open /etc/securetty file
server-etc-securetty
In the end of file add pts/0 and save the file
server-pts
Go back on windowclient system and try again to login from root user
windowclient-root-sucess
In this article I have configured Telnet server on RHEL7 system in LAB environment.
 

No comments:

Post a Comment