This article covers how to create a new SSH key pair and set up an SSH key-based authentication. You can set up same key to multiple remote hosts. Also, you will learn how to disable SSH password authentication. SSH stands for Secure Shell and works as a method to establish remote connections between computers. SSH is usually used to log in and manage a remote server.
SSH key pairs can be used to authenticate a client to a server. The client creates a key pair and then uploads the public key to any remote server it wishes to access. This is placed in a file called authorized_keys within the ~/. ssh directory in the user account's home directory on the remote server.
To Disable Password Authentication:
Disabling password authentication is a security precaution. It prevents brute-force attacks against attempting to log in to the server.
1. Start by logging into the remote server:
$ ssh user@hostname
2. Next, edit the sshd_config file in a text editor of your choice (we are using nano):
$ sudo nano /etc/ssh/sshd_config
3. Find and modify the following lines to look as follows:
4. Write the changes, then exit the editor. Restart the SSH service by entering the following:
$ sudo systemctl restart ssh