How to disable remote logon by the root user

Source: Internet
Author: User
The purpose of limiting the remote login of root users is to leave it alone. The following are several methods: Method 1: modify the/etc/ssh/sshd_config file and change PermitRootLogin to no, then restart the ssh service. /Etc/rc. d/sshdrestart method 2...
The purpose of limiting the remote login of root users is to leave it alone. The following are several methods: Method 1: modify the/etc/ssh/sshd_config file and change PermitRootLogin to no, then restart the ssh service. /Etc/rc. d/sshd restart Method 2: in the/etc/default/login file, add a line of setting command: CONSOLE =/dev/tty01 to take effect immediately and no need to reboot. In the future, users can only log on to the console (/dev/tty01) as root, thus limiting root remote logon. However, root logon is also restricted, it brings a lot of inconvenience to the administrator's daily maintenance work. Www.2cto.com method 3: 1. to restrict root remote logon, you must first determine which users are remote users (that is, whether to perform telnet logon through another Windows or UNIX system) and which users are lan users. Use the following shell program to achieve this goal. TY = 'tty | cut-B 9-12 'wh = 'finger | cut-B 32-79 | grep "$ TY" | cut-B 29-39 'KK = 'tty | cut- B 6-9 'If ["$ KK" = "ttyp"] Then WH = $ WH Else WH = "local" Fi above the Shell command program, WH is the host IP address of the logon user. if the ing between the IP address and the host name is defined in the/etc/hosts file, WH is the host name of the logon user. Assume that the IP address of the terminal server connected to the LAN is 99.57.32.18, add a line in the/etc/hosts File: www.2cto.com 99.57.32.18 terminal_server, all terminal servers connected to the host through the 99.57.32.18 terminal server, WH is the same value, that is, the terminal server name terminal_server. 2. in the root. profile file, different processing is performed based on the WH value, thus limiting root remote login. Trap 1 2 3 9 15 If ["$ WH" = "local"-o "$ WH" = "terminal_server"] Then Echo "Welcome ...... "Else Exit Fi method 4: sometimes, for the convenience of work, some computers in the Lan are allowed to log on as the root user. for example, to allow the root user to log on to a computer whose IP address is 99.57.32.58, in the preceding method, we need to add two points: 1. in the/etc/hosts file, add a line: 99.57.32.58 xmh. 2. in the preceding Shell section, modify www.2cto.com If ["$ WH" = "local"-o "$ WH" = "terminal_server"]: if ["$ WH" = "local"-o "$ WH" = "terminal_server"-o "$ WH" = "xmh"] method 5: After the above processing, there is still the possibility of using the su command to become a root user after a common user logs on, thus achieving the root remote login goal. To prevent remote root logon using this method, you must restrict normal users from executing the su command: 1. change the su command owner to root; 2. change the su command permission to 700 author comexpert.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.