ssh using keys (avoid password)

use public keys to authenticate 2 servers ”’Server1”’ and ”’Server2”’

=== on Server1 ===

generate keys
* do not input a password
* this will generate 2 files: ”id_rsa” (p[rivate key) and ”id_rsa.pub” (public key)
cd $HOME/.ssh
ssh-keygen -t rsa

add the public key to remote server
ssh-copy-id -i id_rsa.pub username@server2.local

=== on Server2 ===

this is optional, unless you also want server2 can ssh to server1 without password

ssh to server2 (from server1) and do the same thing again
ssh server2
cd $HOME/.ssh
ssh-keygen -t rsa
ssh-copy-id -i id_rsa.pub username@server1.local