The following steps can be used to ssh from one system to another without specifying a password.
Step 1. On the client run the following commands:
ssh-keygen -t rsa
The output will look like this:
root@client:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
Step 2. Now run the following commands:
ssh root@server mkdir -p .ssh
You will prompted for the password.
Step 3.Now run:
cat .ssh/id_rsa.pub | ssh root@server ‘cat >> .ssh/authorized_keys’
You will prompted for the password again.
From now on you can log into B as b from A as a without password.