How to login to ssh using public key authentication
First you have to create a public, private key pair. For this you can use the command-line tool sshkey-gen.
Change the directory to “~/.ssh” (create it, if it does not exist).
Create key pair
Now let’s create the key pair. In this example I will use RSA with 4096 Bit
ssh-keygen -t rsa -b 4096
Enter a passphrase if you want but you don’t have to. I recommend to enter a passphrase.
Transfer public key to ssh server
To transfer the public key to the ssh server you can use ssh-copy-id.
ssh-copy-id -i ~/.ssh/id_rsa.pub HOST
Login with key
Now you should be able to login with the created key.