step 1, use ssh-keygen
on A to generate a key-pair
step 2, copy the content of the public key to B (append to ~/.ssh/authorized_keys)
step 3, try to connect from A using ssh -i path_to_private_key user@B
, and enter yes
to permenately save host B on A (then it won't ask again)