Your Aim
You want the use of Linux and OpenSSH to automate your tasks. Therefore 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
First log in on a as user A and generate a pair of authentication keys. Do not enter a passphrase:
[Email protected]:~> ssh-keygen-t rsagenerating 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 have been saved IN/HOME/A/.SS H/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 [email protected]
Now use ssh to create a directory ~/.ssh as User B on B. (the directory may already exist, which is fine ):
Finally append a ' s new public key to [e-mail Protected]:.ssh/authorized_keys and enter B ' s password one last time:
From now on you can log into B as B from a as a without password:
[Email protected]:~> ssh [email protected]
A Note from one of our readers:depending in your version of SSH you might also has to do the following changes:
- Put the public key in . Ssh/authorized_keys2
- Change the permissions of . SSH to
- Change the permissions of . Ssh/authorized_keys2 to 640
"Reprint" SSH login without password password-free login