Disable Direct Root Login and User Access via SSH to Server

Everybody knows, including hackers and attackers that all Linux and UNIX flavored systems come with a all powerful root user account, which once get compromised, mean all hell breaks loose. So it’s a good security practice to disable the ability for root user to able to login and gain access to the server system via SSH directly (of course, the system must have disabled FTP access). After disabling direct root SSH remote login, the chance for the brute force hacking to success is greatly reduced.

To turn off and disable direct root SSH login, follow this simple tutorial:

IMPORTANT: Make sure you have another account (preferably belongs to wheel user group too) which is able to login via SSH remotely, and able to SU to root user account. Else you risk been locked out from your server.

  1. SSH into server and login as root.
  2. In command shell, use pico or vi to edit sshd_config file by typing one of the following commands:

    pico /etc/ssh/sshd_config
    vi /etc/ssh/sshd_config

  3. Scroll down the SSH server configuration file and locate a line like below:

    #PermitRootLogin yes

  4. Uncomment the line by removing the hash symbol (#), and then change the “yes” to “no”. The final line should look like below:

    PermitRootLogin no

  5. Save the config file. In pico, press Ctrl-o, follow by Ctrl-x. In vi, type :wq and press Enter.
  6. Restart SSH server by typing the following command in command line, and press Enter:

    /etc/rc.d/init.d/sshd restart

  7. Logout from SSH connection. Try to login as root, it should fail with Access denied error. To access root account, login with your own user name and password, and then SU to root.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

disable remote root login - enable remote root - disable root remote login - ssh root login disable Solaris - linux disable root remote login - Solaris restrict direct user login - accessing ROOT login - ssh virtualbox "access denied" - disable remote login in linux - how to disable ssh iphone 2009 - remotely logging into freebsd root - ssh root locked out what do - ssh root locked out - su access denied debian ssh - unix:logout main root user - disable root on freebsd - disallow remote ssh login - remove root login ssh - configure openbsd www authoring not root - disable remote root ssh login - disable ssh server - disable ssh server iphone - disable sshd server iphone - how to create root user in freebsd - how to login linux server without having root - linux disable ssh login for user - Menonaktifkan ssh di freebsd - preventing admin from connecting via ssh direct - ssh root login access denied - ssh remove root access - ssh root access denied freebsd - +aix +access +deny +for +root +by +ssh - disable direct remote root login over ssh session - disable Linux root user - disable root remote login on solaris - disallow user to log in via ssh - disable remote root ssh - enable remote root login with ssh - freebsd command login user - how to disable remote login for root user - linux disable remote login - red hat login as: root access denied - sshd2 refused connection freebsd - access denied ssh root - aix disable direct root login - allow root login - diable root log from remote - disable ssh login debian user - disable remote login linux - disable ssh access for users linux -