If you are using Linux and OpenSSH to automate your tasks, you
will almost always find it easier to have an automatic login that does
not require a password. This is especially true if you are using
rcp for easy file transfers.
Let's configure SSH (version 2) with a secure key to bypass password login from host A / user a to Host B / user b.
Step by step
First login on system A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> 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: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
ssh to create a directory
~/.ssh as user b on B. (The
directory may already exist, which is fine, although in that case you
may have to manually reset the mode with
chmod 700 ~/.ssh ):
a@A:~> ssh b@B mkdir -p .ssh -m 700 b@B's password:
Finally append a's new public key to
enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys2' b@B's password:
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B
If that does not work, from system A do:
a@A:~gt; ssh b@B 'chmod 640 ~/.ssh/authorized_keys2'
and you should be good to go.