Tuesday, 2 October 2012

Restrict Root SSH Login on Linux




One of the biggest security holes you could open on your server is to allow directly logging in as root through ssh.

We can Disable Root SSH Login, we’ll need to edit the sshd_config file, which is the main configuration file for the sshd service. The location will sometimes be different, but it’s usually in /etc/ssh/. Open the file up while logged on as root.

  " vi /etc/ssh/sshd_config "

Find this section in the file, containing the line with “PermitRootLogin” in it.

    #LoginGraceTime 2m
    #PermitRootLogin no
    #StrictModes yes
    #MaxAuthTries 6

Make the line look like this to disable logging in through ssh as root.

    PermitRootLogin no

Now you’ll need to restart the sshd service:

  " /etc/init.d/sshd restart "

No comments:

Post a Comment