First of all do you need to have SSH access on both machines that you want to set up authentication with. I will describe how to do this mostly manually with command prompt / terminal.
Log in with SSH to the machine you want to be authenticated. From here you can easily generate a RSA key pair by running the command:
This will create a .ssh/ directory with a id_rsa and a id_rsa.pub file inside.
The id_rsa file is your private key, which you should always keep secret. The other id_rsa.pub file is your public key which we will use to authenticate your machine.
To output the key to the console, run the cat command:
The output will look something like this:
Copy this to your clipboard, we will use this to authenticate your machine.
Now log in to your remote machine with SSH. Here you will also need to make a .ssh/ directory with the file authorized_keys inside it.
You can run the command nano to make and edit the file:
Then you just paste the contents of id_rsa.pub and save.
Some hosting providers will also have an easy method of adding SSH keys:
Now have you successfully authenticated your local machine for your remote machine!