In client side, make sure current directory is ~/:
- generate public key & private key
ssh-keygen -t rsa
- make ~/.ssh directory in server side
ssh b@B mkdir -p .ssh
- add client's public key to server's authorized keys
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'