These steps assume you already have a public SSH key, if not, create one
SSH-Copy-Id is an easier way to upload ssh keys, however, it does not work on all devices.
ssh to the remote server using your password.
If it is not already created, create the authorized_keys file under the .ssh folder
touch ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys vi ~/.ssh/authorized_keys
Add your public key to the end of the authorized_keys file
Ensure that the correct owner and permissions are on the files.
The .ssh directory should be
chmod 700 .ssh
And the authorized_keys file should be 600
chmod 600 ~/.ssh/authorized_keys
Both should be owned by the user. Change username to your username.
sudo chown -R username:username .ssh/authorized_keys