SSH keys enable you to access a remote machine using ssh protocol using your public/private ssh keys combination.
You can choose not to apply a password, and thus access the machine directly, or you can add more security to the keys and apply a password.
The following command generates a pair of ssh authentication keys for your machine
1
| |
The default keys will be created under your home directory in the .ssh directory, id_rsa and id_rsa.pub
id_rsa: This is your private key, keep it safe and never share it with anyone. It should not be readable by anyone.
id_rsa.pub: This is your public key, you share it with the server or service you want to authenticate against.
You will also need to apply the following permissions to the keys and the .ssh directory,
1 2 | |
To add your keys to a remote server just copy the id_rsa.pub file to that server and add it to the authorized_keys file,
also don’t forget to fix the permissions.
1 2 3 | |
It’s always a good practice to add a password to your keys.