Telnet installation

Telnet installation

1. Telnet installation

(1) Log in to the target host to check whether the telnet service is normal

[root@localhost ~]# telnet localhost
-bash: telnet: command not found

(2) Telnet installation package

telnet-client:telnet 客户端  
telnet-server:telnet服务端        
       xinetd:网络服务器超级守护进程  

It can be roughly understood that most versions of Linux have telnet-client installed by default, and telnet-server needs to be installed by the user.

xinetd is the super daemon process of the Linux system. It resides in the background for a long time and listens for requests from the network to start the corresponding service. And telnet is one of the services under the jurisdiction of xinetd.

(3) Check if there are rpm installation packages related to telnet: rpm -qa | grep telnet

[root@localhost ~]# rpm -qa | grep telnet
[root@localhost ~]#  

If there is no input, it means that it is not installed. For security reasons, telnet-server.rpm is not installed by default, and the telnet client is standard. That is, the following software is installed by default.

[root@localhost ~]# yum list | grep telnet
telnet.x86_64                              1:0.17-64.el7          @base         
telnet-server.x86_64                       1:0.17-64.el7          base  

The representative of @base has already installed it, of which telnet.x86_64 is telnet-client, which has been installed by default, and telnet-server is installed below

yum install -y telnet-server.x86_64

(4) Restart the xinetd daemon

Since the Telnet service is also guarded by xinetd, after installing telnet-server, you must restart xinetd to start the telnet service

service xinetd restart

If xinetd is not installed, just install it:

[root@localhost ~]# yum list | grep xinetd
xinetd.x86_64                              2:2.3.15-13.el7        @base

[root@localhost ~]# yum install -y xinetd.x86_64

(5) Restart the xinetd daemon to start Telnet

Let's first check if TCP port 23 is open normally

[root@mdw xinetd.d]# netstat -tnl |grep 23 
tcp6       0      0 :::23                   :::*                    LISTEN

If the above line exists, the service is already running. If the netstat command returns nothing, we'll have to move on to a more in-depth configuration.

(6) Modify the Telnet configuration file

Query the directory where all configuration files managed by xinetd.d are located, and set the Telnet service to start by default.

[root@localhost xinetd.d]# cd /etc/xinetd.d  
[root@localhost xinetd.d]# ls  
chargen-dgram   cvs            daytime-stream  discard-stream  echo-stream  tcpmux-server  time-dgram  
chargen-stream  daytime-dgram  discard-dgram   echo-dgram      rsync        telnet         time-stream  
[root@localhost xinetd.d]# vim telnet  
  
# default: on  
# description: The telnet server serves telnet sessions; it uses \  
#       unencrypted username/password pairs for authentication.  
service telnet  
{  
        disable = no    # 启用  
        flags           = REUSE     # socket可重用 
        socket_type     = stream    # 连接方式为 TCP 
        wait            = no        # 为每个请求启动一个进程 
        user            = root      # 启动服务的用户为 root 
        server          = /usr/sbin/in.telnetd # 要激活的进程  
        log_on_failure  += USERID   # 登录失败时记录登录用户名     
}  

Back up the telnet file, open vi again, and assign the disable value to no.

  1. To configure a list of clients allowed to log in, add

    only_from = 192.168.0.2 #Only 192.168.0.2 is allowed to log in

  2. If you want to configure a list of clients that are prohibited from logging in, add

    no_access = 192.168.0.{2,3,4} # Disable 192.168.0.2, 192.168.0.3, 192.168.0.4 login

  3. If you want to set open hours, join

    access_times = 9:00-12:00 13:00-17:00 # Only these two hours are open every day (our working hours: P)

  4. If you have two IP addresses, one is the IP address of the private network such as 192.168.0.2, and the other is the IP address of the public network such as 218.75.74.83, if you want users to log in to the telnet service only from the private network, then add

    bind = 192.168.0.2

    For the specific meaning and syntax of each configuration item, please refer to the xined configuration file attribute description (man xinetd.conf)

  5. Configure the port and modify the services file:

    vim /etc/services

    telnet 23/tcp
    telnet 23/udp

    The default port of telnet is 23. This port is also the main target of hacker port scanning. Therefore, it is best to modify this port. The modification method is very simple, that is, modify the number 23 and change it to a larger number, such as 61123. Note that the port numbers below 1024 are reserved for the Internet, so it is best not to use them, and you should also be careful not to conflict with the ports of other services.

Restart the Telnet service again and check the port

service xinetd restart
netstat -tnl |grep 23

(7) Use telnet to log in remotely again

The username and password are the username and password configured on the Linux system.

[root@localhost xinetd.d]# telnet localhost
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Kernel 3.10.0-514.el7.x86_64 on an x86_64
localhost login: hadoop
Password: 
Last login: Sun Apr 22 19:36:32 on pts/1
[hadoop@localhost ~]$ 

Note: In general, root is not allowed to log in remotely. You can log in with an ordinary account first, and then use su - to switch to the root user.

2. How to open Telnet service in Win8

Steps to enable Telnet in Win8: http://www.win8.net/jiaocheng/20150927/2539.html

  1. Go to Control Panel -> Programs -> Programs and Features -> Enable and Disable Windows Features

  2. Check "telnet server" and "telnet client". Wait for the installation to complete.

Three, telnet command

linux telnet command: https://www.cnblogs.com/gyrgyr/p/7954090.html


Record a little bit every day. Content may not be important, but habits are!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324916868&siteId=291194637