By default, the root user is created as the first user on every Linux system. The root user has the highest rights. With the root user, you have access to all commands and files and full read, write and executable permissions. If this user account is used improperly or inappropriately, it may have a significant impact on your server. 

To disable the SSH root login:

  • Open the SSH configuration file sshd_config with the text editor vi:

    vi /etc/ssh/sshd_config

  • In the line PermitRootLogin yes replace the word Yes with the word No.

  • Save the file.

  • Restart the service.

    Ubuntu

    service ssh restart

    CentOS 7

    systemctl restart sshd