For the longest time to achieve passwordless login on a server I was doing the following:
- manually connected to the server
 - created the 
.sshdirectory if it didn’t exist - created the 
authorized_keysfile inside that directory and pasted the contents of previously copied public key - crucial step was to set the correct permissions: 
700for the directory and600for the file 
But as with many things, there’s a script for that! It’s named ssh-copy-id and it’s part of the openssh package.
Copying the public key to a server myserver is as easy as doing this:
ssh-copy-id user@myserver
And if you need to specify a non-default public key just use the -i option:
ssh-copy-id user@myserver -i ~/.ssh/some_id.pub