# How to enable or disable public key authentication in SSH

SSH server in most systems is by default configured to allow public-key authentication. The method will enable you to use your public and private key pair to log in to an SSH server without using a username and password.

You can disable public key authentication if your private key is compromised or for any other reason by configuring your SSH server

Public key authentication method for SSH could be enabled or disabled by configuring PubkeyAuthentication directive in sshd\_config file on the server.

##### Steps to enable or disable public key authentication in SSH:

Launch your preferred terminal application.  
Open SSHd configuration file with your favourite text editor.

```bash
nano /etc/ssh/sshd_config
```

Search for <span style="color: rgb(224, 62, 45);">**PubkeyAuthentication**</span> and set the option to **<span style="color: rgb(224, 62, 45);">yes</span>** or **<span style="color: rgb(224, 62, 45);">no</span>**.

To disable <span style="color: rgb(224, 62, 45);">**PubkeyAuthentication**</span> then set to <span style="color: rgb(224, 62, 45);">**no**</span> and you will login with username and password.

To enable <span style="color: rgb(224, 62, 45);">**PubkeyAuthentication**</span> then set to **<span style="color: rgb(224, 62, 45);">yes</span>** and you will login with Public Key Authentication.

<span style="color: rgb(224, 62, 45);">**Ins0mniA**</span>