How to disable public key authentication in SSH

SSH in most system by default allow public key login. You can disable it with these simple steps if you somehow need to;

  1. Open SSHd configuration file with your default editor.
    $ sudo vim /etc/ssh/sshd_config
  2. Search and set PubkeyAuthentication option to no. Add the line if it doesn't already exist.
    PubkeyAuthentication no
  3. Reload or restart SSHd