In key-based
authentication, we need to generate SSH key pairs and the pair use for
authentication. The private key is used for client machine and public key
uploaded to the remote machine.
Step 1: Create a hidden .ssh directory on the user home directory if not created:
[root@linuxcnf ~]# mkdir –p
/home/<username>/.ssh
|
Step 2: Create or edit the authorized_keys file inside the .ssh directory and paste the public key into this file at the end:
[root@linuxcnf ~]# vi
/home/<username>/.ssh/authorized_keys
|
Step 3: Set the required strict mode permissions:
[root@linuxcnf ~]# chown
username.username /home/<username>/.ssh
[root@linuxcnf ~]# chown
username.username /home/<username>/.ssh/authorized_keys
[root@linuxcnf ~]# chmod 700
/home/<username>/.ssh/authorized_keys
[root@linuxcnf ~]# chmod 600
/home/<username>/.ssh/authorized_keys
|
Done! SSH to the server using SSH Key
authentication.
No comments:
Post a Comment