+1 vote
in Linux by
What is Key-based authentication? Explain.

1 Answer

0 votes
by

Linux Sale Whizlabs

Answer: There are various methods to enter into the servers. One of the ways to log in is using password-based authentication, but that is not secure. So, we need a method that is secured.

One of the ways to achieve the security is to use Key-based authentication. To use this type of authentication, we have to disable the password-based authentication. So, there is a procedure to set up this authentication which is as follows:

We have to get the SSH key pair using below command:

$ ssh-keygen -t rsa

1) It will generate the public/private rsa key pair.

2) Enter file where you want to save this generated key (/home/username/.ssh/id_rsa):

3) It will prompt you for the same location, i.e. ~/.ssh/id_rsa for the key pair. Press enter if you want to confirm the same location. Else, if you want to provide any other location, enter that and confirm the same.

4) Now copy ~/.ssh/id_rsa.pub into the ~/.ssh/authorized_keys that will be located where you have to connect.

5) Now, we have to provide the permissions to the file as per below command:

$ chmod 600 ~/.ssh/authorized_keys

6) Now try to sshthe machine you want to connect, and you will see that you are able to login to the machine without a password.

7) If you are confirmed that key-based authentication is working fine, disable the password-based authentication.

8) Go to the path /etc/ ssh/sshd_config

9) set the following property as no.

PasswordAuthentication no

Related questions

0 votes
asked Dec 24, 2023 in Linux by GeorgeBell
+1 vote
asked Jan 28, 2020 in Cybersecurity Prologue by AdilsonLima
...