[LINUX] Stop SSH password authentication and switch to key authentication completely

In the previous article, I wrote how to generate the public and private keys required for an SSH connection.

Finally, I will show you how to stop password authentication. As a result, no one can start an SSH connection with password authentication, and instead, you can start an SSH connection only with public / private key authentication.

MainPC


$ sudo vi /etc/ssh/sshd_config

If you hit the above, the configuration file for ssh will be edited with vim. Search for the following in vim:

MainPC


PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no

I just mess with yes and no in the above part ... A surprising pitfall is that by default the top two commands are commented out (# ~). With this, no matter how much you change it to yes or no, it will not be reflected as a setting item lol Be sure to remove # to change and save the value.

Now, reboot the ssh system.

MainPC


$ sudo systemctl restart sshd

Now try the previous article again. Perhaps password authentication is turned off.

Recommended Posts

Stop SSH password authentication and switch to key authentication completely
Log in to Raspberry PI with ssh without password (key authentication)
[SSH] About public key authentication and EC2
How to set up public key authentication in ssh
[Ansible] How to use SSH password authentication when executing ansible
[Amazon Linux 2] Change from public key authentication to password authentication
Key additions to pandas 1.1.0 and 1.0.0
[Linux setting series] How to set public key authentication / ssh-keygen / ssh key / authorized_keys
How to switch between Linux and Mac shells