ssh-keygen -t rsa -b 2048 # Enter twice
# Will create file ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
ssh-copy-id <server-user>@<server-ip> # This will ask you ssh-sever-password
# Test your work. It's should automate without password.
ssh <server-user>@<server-ip>
On server side, ssh-copy-id
will create ~/.ssh/authorized_keys file.
https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password