SSH keypairs are a combination of a public key that you set on your remote machines and a private key that you should store securely and use for accessing the remote machines. They add both better security than passwords and less effort to remember a different passwords for each server you log on.

 

Once you have one, you’ll get two files the private key which you should keep very secure and safe and the public one which you can provide and share publicly without concerns.

 

To use your SSH key for authentication you add your public key to the remote machines authorized keys.

 

It’s a file in the .ssh folder, in the home directory of your user, ex.:

 

/home/admin/.ssh/authorized_keys

 

If the file doesn’t exist, simply create it.

nano ~/.ssh/authorized_keys

or

vim ~/.ssh/authorized_keys

 

Add your private key to the authorized_keys file, it will look something like this:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFM9wOKgSxS1WlsOYMqScJuvwyJQ1cKD7Vqh46+LwuxTo0mVKs25JKrn6F0Wn7Ua3Ghb3BiW7BzLWm9kh3/0X6R+lvJe52g/bO347JzUBsZC8kiwz2IuYgwyAT9eILBcVCcuSKisPTTFlhlzOonKefQvRmECzbdLxJR0xn30Z18tVtdazwexPU46/EwlKhB0TWfCtm8LuOMbAIhIK61z8dgL+BB0pHfzeuJdbhbqDFNq9sF8B80lNEmhq7pFyTOyb1isXvLKbVzyp1uLWJJUgQMZYhem4XCltosjr7EvDlPEfW6pQXskyJGOJ1U4BUZrMxYzBaFYwQp8syqTfgm4Vf admin@ubuntu

 

You can add more than one authorized key per user, just put each of them on a new line.

 

With that done, you are now authorized to connect using your private key.

Was this answer helpful? 0 Users Found This Useful (0 Votes)