How to disable the direct root login via SSH

This tutorial will show you how to disable the direct root login on a computer with Unix/Linux operating system.

To stop the direct root access you must edit the SSH configuration file located at ”/etc/ssh/sshd_config”

Open the file with your favorite editor, for example VIM, and locate the ”Authentication” section. There set PermitRootLogin to be ”no” as in the example bellow.


  1. # Authentication:
  2.  
  3. #LoginGraceTime 2m
  4. [b]PermitRootLogin no[/b]
  5. #StrictModes yes
  6. #MaxAuthTries 6

Once you are ready save the file and restart the ssh service.

WARNING: DO NOT FORGET TO ALLOW DIFFERENT USER ACCESS BEFORE DENYING THE ROOT ONE!

This can easily done with this commands:

useradd newuser #creates the user
passwd newuser #set the password for the ”newuser”

If you have further questions you may ask them in our forum.

Tags

Filed Under: SSH

Anthony Gee About the Author: Anthony G. is an IT specialist with more than 9 years of solid working experience in the Web Hosting industry. Currently works as server support administrator, involved in consultative discussions about Web Hosting and server administration. One of the first writers in the Onlinehowto.net website, now writing for Free Tutorials community - he is publishing tutorials and articles for the wide public, as well as specific technical solutions.

Leave a Reply