You have to create the
.ssh directory and the
authorized_keys file the first time.
Set the right permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
The permissions are important! It won’t work without the right permissions!
Now you can add the public key to the
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
You have to add the public key of your computer to the
authorized_keys file of the computer you want to access using SSH Keys!
As terdon mentioned you can also just use this command:
This will put your
id_rsa.pub (in your
~/.ssh directory) in the remote computer’s
authorized_keys file, creating the
.ssh directory and
authorized_keys file with the right permissions if necessary.