Even though SSH login is protected by using passwords for the user account, we can make it more secure by using key-based authentication into SSH.
To see how key-based authentication works, we need two Linux systems (in our example, both are Ubuntu systems). We should have the OpenSSH server package installed on them.
To use key-based authentication, we need to create a pair of keys – a private key and a public key:
- On the client or local system, execute the following command to generate the SSH key pairs:
ssh-keygen -t rsa
While creating the key, we can accept the default values or change them as we wish. It will also ask for a passphrase, for which you can choose anything or leave it blank.
- The key-pair will be created in the location -
~./ssh/
. Change to this directory and then use thels -l
command to see the details of the key files:
We can see that the id_rsa
file can be read and written only by the...