Install Telnet on CentOS/RHEL/Scientific Linux 6 & 7
Title: Install the Telnet Statement on CentOS/RHEL/Scientific Linux 6 & 7:
Before installing and using Telnet, remember the following points.
- It is a bad idea to use Telnet in a public network (WAN. It transfers the login data in plaintext format. Everyone can see the plaintext.
- If you still need Telnet, we strongly recommend that you only use it within the LAN.
- You can use SSH as an alternative. However, make sure that you do not use the root user to log on.
What is Telnet?
Telnet is a protocol used to remotely log on to a computer through a TCP/IP network. Once a connection is established with a remote computer, it becomes a virtual terminal that allows you to communicate with the remote computer.
In this tutorial, we will show you how to install Telnet and access the remote system through Telnet.
Install
Open the terminal and enter the following command to install telnet:
yum install telnet telnet-server -y
Now telnet has been installed on your server. Next, edit the file/etc/xinetd. d/telnet:
vi /etc/xinetd.d/telnet
Set disable = no:
# 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 exit the file. Remember, we don't have to do this in CentOS 7.
Run the following command to restart the telnet service:
In CentOS 6.x:
service xinetd start
Enable this service every time it is restarted:
On CentOS 6:
chkconfig telnet onchkconfig xinetd on
On CentOS 7:
systemctl start telnet.socketsystemctl enable telnet.socket
Allow telnet's default port 23 to pass through the firewall and vro. To enable the telnet port to use the firewall, edit the following file in CentOS 6. x:
vi /etc/sysconfig/iptables
Add the following line "-a input-p tcp-m state -- state NEW -- dport 23-j ACCEPT ":
# 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 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-prohibitedCOMMIT
Save and exit the file. Restart the iptables service:
service iptables restart
In CentOS 7, run the following command to enable the telnet Service to use the firewall.
firewall-cmd --permanent --add-port=23/tcpfirewall-cmd --reload
That's it. Now the telnet service can be used.
Create user
Create a test user. For example, the user name is "sk" and the password is "centos":
useradd skpasswd sk
Client Configuration
Install the telnet package:
yum install telnet
In DEB-based systems:
sudo apt-get install telnet
Now, open the terminal and try to access your server (remote host ).
If your client is a Linux system, open the terminal and enter the following command to connect to the telnet server.
telnet 192.168.1.150
Enter the username and password created on the server:
Sample output:
Trying 192.168.1.150...Connected to 192.168.1.150.Escape character is '^]'.Kernel 3.10.0-123.13.2.el7.x86_64 on an x86_64server1 login: skPassword: [sk@server1 ~]$
As you can see, you have successfully accessed the remote host from the local machine.
If your system is windows, choose Start> RUN> command prompt.
In the command prompt, enter the following command:
telnet 192.168.1.150
192.168.1.150 is the IP address of the remote host.
Now you can connect to your server.
That's it.
OK!