SSH Login With Keys
From Your Computer
Make sure you have created a private/public key pair. There are tons of articles online about how to use openSSH (for real operating systems) or some convoluted third-party app like Pagent or Putty to generate an SSH key.
Copy the contents of your id_rsa.pub file (you can use this public key on multiple services, BTW, they do not need to be unique per service.
On The Server
Login with your user account using an old-fashioned username/password.
Now let’s setup a way to login from your computer without typing passwords:
press i to enter insert mode
paste in the contents of that id_rsa.pub file you copied earlier
press <esc> to exit insert mode
type :wq! to quit vim
If the permissions of the .ssh directory and files within are not correct you cannot login. chmod 777 (allow anyone to do anything) will not work as the SSH app checks for gaping security holes in file and directory permissions when authorizing access.
chmod 644 authorized_keys
chmod 700 .ssh
Creating Login Directories
As root type:
Useful if a user account was created without the “create login directory” option, which I always seem to forget.