SSH key authentication lets users log into servers without the need to use their user’s passwords which increases security.
Step 1: Create a key (if you don’t already have one)
Note: for extra security, add a passphrase to your key when prompted.
Step 2: Copy the key to your server
1
| cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
|
Step 3: Disable root login and password login for users
Modify /etc/ssh/sshd_config
configuration file to include the following (if not already there):
1
2
| PermitRootLogin no
PasswordAuthentication no
|
Step 4: Restart your ssh
service
1
| sudo systemctl reload sshd.service
|