How to Install Telnet in CentOS / RHEL / Scientific Linux 6.4

by
Share this Article: Facebook0Google+0Twitter10LinkedIn0Reddit0StumbleUpon0

Telnet is a network protocol which is used to connect to remote computers over TCP/IP network. You can make a connection to a remote host using telnet. Once you establish a connection to the remote computer, it becomes a virtual terminal and will allow you to communicate with the remote host from your computer.

Installing telnet on CentOS 6.4

Open your terminal and type the following command to install telnet:

[root@server ~]# yum install telnet telnet-server -y

Now the telnet has been installed in your server. Next open the telnet configuration file /etc/xinetd.d/telnet and set disable = no:

[root@server ~]# vi /etc/xinetd.d/telnet 
# default: on
# description: The telnet server serves telnet sessions; it uses \
#       unencrypted username/password pairs for authentication.
service telnet
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
        disable         = no
}

Save and quit the file. Now restart the telnet service using the following command:

[root@server ~]# service xinetd start
Starting xinetd:                                           [  OK  ]

Make this service to start automatically on every reboot:

[root@server ~]# chkconfig telnet on
[root@server ~]# chkconfig xinetd on

Allow the telnet default port 23 through your firewall and Router. To allow the telnet port through firewall, open the file /etc/sysconfig/iptables and enter the lines as shown in red color:

[root@server ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p udp -m state --state NEW --dport 23 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Save and exit the file. Restart iptables service:

[root@server ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

Thats it. Now telnet server is ready to use.

Create a test user called “sk” with password “centos“:

[root@server ~]# useradd sk
[root@server ~]# passwd sk
Changing password for user sk.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.

Now go to your client system and try to access your server(remote host).

If your client is Linux system, open the terminal and type the following command to connect to telnet server. Enter username and password:

sk@sk:~$ telnet 192.168.1.200
Trying 192.168.1.200...
Connected to 192.168.1.200.
Escape character is '^]'.
CentOS release 6.4 (Final)
Kernel 2.6.32-358.el6.i686 on an i686
login: sk
Password: 
[sk@server ~]$

If your client is windows system, then go to Start -> Run -> Command Prompt.

In the command prompt, type the command:

telnet 192.168.1.200

Where 192.168.1.200 is your remote host IP address.

Now you will be able to connect to your server.

For questions please refer to our Q/A forum at : http://ask.unixmen.com/

Share this Article: Facebook0Google+0Twitter10LinkedIn0Reddit0StumbleUpon0