What are the benefits of key based authentication?
Key based authentication provides two major benefits. The first, you can login without a password (If you didn’t set it up to use password protection). Second, the lack of using a password stops any unauthorized password uses or cracking attempts.
How do I setup key based authentication?
Follow these steps to create a public/private key pair, get them installed and ready for use on your ssh server:
- Create a key pair on server connection client, for example, PuTTY
You’ll need to repeat this process for each machine you connect to the server with
$ ssh-keygen -t rsa
- a. Id_rsa – Your private key
b. Id_rsa.pub – Your public key
- Choose whether or not you want a password upon setup by hitting the enter key or adding one
Anyone who has access to your local machine will be granted access automatically
- Set private key permissions
1$ chmod 700 ~/.ssh1$ chmod 600 ~/.ssh/id_rsa
- Copy and install your public key (id_rsa.pub) to the servers authorized_keys list
1$ cat id_rsa.pub > ~/.ssh/authorized_keys
- Set your server permissions
Anyone using your local machine will be granted access automatically
1$ chmod 700 ~/.ssh1$ chmod 600 ~/.ssh/authorized_keys
- Set proper SELinux context
1$ restorecon -Rv ~/.ssh