SSH Pubkey Authentication

1. Generate keys in local machine (ssh client)

ssh-keygen -t rsa

It will generate files in $HOME/.ssh/

id_rsa: the private key, keep it secret
id_rsa.pub: the public key

2. Copy id_rsa.pub to remote machine (ssh server) $HOME(remote login home)/.ssh as name "authorized_keys" (file name)

scp $HOME/.ssh/id_rsa.pub remoteLogin@remoteMachine:/home/remoteLogin/.ssh/authorized_keys
or
ssh-copy-id [-i [identity_file]] [user@]machine

3. make sure file/folder permissions

chmod 700 ~
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys