You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don’t want to enter any passwords, because you want to call ssh from a within a shell script.
How to do it
- Log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
ssh-keygen -t rsa
- Use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine)
- Append a’s new public key to b@B:.ssh/authorized_keys
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
- In B, make sure the permission bits of .ssh and authorized_keys are 755 and 644, respectively.
- From now on you can log into B as b from A as a without password.