You want to use Linux/AIX/Unix and OpenSSH to atomize your tasks. Therefore you need an automatic login from hostA as user a to hostB as the same user. You don’t want to enter any passwords, because (for example) you want to call ssh from a within a shell script.
First log in on hostA as user a and generate a pair of authentication keys. Do not enter a passphrase:
# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
Now use ssh to create a directory ~/.ssh as on hostB (the directory may already exist, which is fine):
# ssh user@hostB mkdir -p .ssh
Finally append a’s new public key to user@B:.ssh/authorized_keys and enter b’s password one last time:
# cat .ssh/id_rsa.pub | ssh user@hostB 'cat >> .ssh/authorized_keys'
From now on you can log into hostB as “user” from hostA as a without password:
# ssh user@hostB hostname
Depending on your version of SSH you might also have to do the following changes:
Put the public key in .ssh/authorized_keys2
Change the permissions of .ssh to 700
Change the permissions of .ssh/authorized_keys2 to 640