If you are planning to deploy openssh on any server, you must secure it from hackers. There are several programs on internet which can launch a brute force attack against your ssh server. The first step to a secure ssh server is to disable root access via ssh. Brute force attackers often try to guess root password using dictionary attack.

  1. Open sshd_config file using nano. (You must be root to do this.)
  2. sudo nano /etc/ssh/sshd_config
  3. Scroll down the file until you locate
  4. LoginGraceTime 120
     PermitRootLogin yes
     StrictModes yes
  5. Modify PermitRootLogin to
  6. PermitRootLogin no
  7. Save the file by pressing Ctrl-O and exit nano by pressing Ctrl-X.
  8. Restart SSH with by entering the command below.
  9. sudo /etc/init.d/ssh restart

After restarting SSH, try to connect using the root account. Access will be denied. However , if you want to access root from a remote machine via ssh, login using a normal user account and use su to become root.

Tags: