Sunday, July 24

How to disable TELNET Service in Linux

Note: This exercise is performed on two Linux VMs (Linux1 and Linux2).

Verify TELNET rpm installed?
[root@linux1 ~]# rpm -qa telnet
telnet-0.17-39.el5
[root@linux1 ~]#

Verify that TELNET service is running
[root@linux1 ~]# telnet linux2
Trying 192.168.2.102...
Connected to linux2 (192.168.2.102).
Escape character is '^]'.

    linux2 (Linux release 2.6.18-238.el5 #1 SMP Sun Dec 19 14:24:47 EST 2010) (2)

login: root
Password:

Edit and disable to yes on all the servers
[root@linux1 ~]#  vi /etc/xinetd.d/krb5-telnet

[root@linux1 ~]# cat /etc/xinetd.d/krb5-telnet
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
#              but can also use Kerberos 5 authentication.
service telnet
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/kerberos/sbin/telnetd
        log_on_failure  += USERID
        disable         = yes
}
[root@linux1 ~]#

Restart the service
[root@linux1 ~]# /etc/rc.d/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@linux1 ~]#

[root@linux1 ~]# service xinetd status

Try now
[root@linux1 ~]# telnet linux2
Trying 192.168.2.102...
telnet: connect to address 192.168.2.102: Connection refused
telnet: Unable to connect to remote host: Connection refused
[root@linux1 ~]#