In linux, root users are prohibited from logging on through ssh and access control over ssh.

Source: Internet
Author: User

In linux, root users are prohibited from using ssh to log on and access control over ssh. in Linux, by default, root users can log on through ssh. However, for security reasons, this permission is inappropriate because hackers may crack your root password by brute force and then enter your system. oh, damn it ..... for security reasons, we usually operate on linux systems through common users. When some operations require root permission, run the su-command, or run The sudo command to get the root permission, instead of hitting the root user in the system. Maybe when you shake your hand, you may have performed some risky operations. In this case, how do I disable root logon to the system through ssh? Whether to allow the root user to log on via ssh is implemented by operating the sshd_config configuration file. When an ssh connection is established, the operating system checks the configuration information of related files to determine whether to accept the connection. Therefore, to prevent the root user from logging on through ssh, first find the/etc/ssh/sshd_config file and open the file through the editor. For example, open the file through vim: # vi/etc/ssh/sshd_config find the following line of text in the file: # PermitRootLogin no remove the # sign before the row and make it the following: permitRootLogin no. Then, run the following command in the shell to restart the ssh service #/etc/init. d/sshd restart next when you try to log on to the system as root, there will be a "Access Denied" error message: login as: rootAccess deniedroot@172.31.41.51's password: OK, now we can log on to the system through a common user, If you need root-related operations, you can switch to the root user through the su-command, as shown below: login as: tecmintAccess deniedtecmint@172.16.25.126's password: last login: Tue Oct 16 2012 from 172.16.25.125 [tecmint @ tecmint ~] $ Su-Password: [root @ tecmint ~] # In the same way, if you want to run ssh Login through the root user, you only need to change the start change back, add # In front of the row PermitRootLogin no in the/etc/ssh/sshd_config file to the following and save it. # PermitRootLogin no run the following command to restart the ssh service #/etc/init. d/sshd restart if you have a large number of users in your system and want to allow some users to log on via ssh, while other users are not allowed to log on via ssh. You can do this: first open the file/etc/ssh/sshd_config # vi/etc/ssh/sshd_config and add such a line of text at the end of the file, tecmint and sheena are users that can log on through ssh. AllowUsers tecmint sheena

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.