SSH login without password
Oct 16, 2015
If you want to login from host_A (user a) to Host_B (user b), it is annoying to enter passwords everytime, because you want to call ssh from shell script.
Ok it’s quite easy to do that:
Generate public key
First in host_A you need to generate a pair of authentication keys;
a@A:~> ssh-keygen -t rsa
Create .ssh directory in host_B
Create a directory ~/.ssh as user b on host_B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
Append a’s public key to b
Append a’s new public key to b@B:.ssh/authorized_keys and enter b’s password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
Voilà, from now on you can log into B as b from A as a without password:
a@A:~> ssh b@B