Share!

SSH in most system by default allow public key authentication. This means that you can use your public and private key pair to log in to a server via SSH.

You can disable SSH public key authentication on the server side if your private key has been has been compromised or for any other reason by configuring SSHd configuration file at the terminal.

Disable public key authentication in SSH:

  1. Launch your preferred terminal application.
  2. Open SSHd configuration file with your favourite text editor.
    $ sudo vi /etc/ssh/sshd_config
    [sudo] password for user:
  3. Search for PubkeyAuthentication and set the option to no.
    PubkeyAuthentication no

    Add the line if it doesn't already exist and remove the # at the beginning of the line if exists.

  4. Reload or restart SSH server service.
    $ sudo systemctl restart sshd

Guide compatibility:

Operating System
Ubuntu Linux
Debian Linux
Red Hat Enterprise Linux
Fedora Linux
CentOS Linux
openSUSE Linux
SUSE Linux Enterprise Server
FreeBSD
OpenBSD
NetBSD
macOS