[Host A] ---ssh no password---> [Host B]
1. Generate a new public/private key pair.
execute the following command on management host.
cd ~/.ssh
ssh-keygen -t rsa
this will generate a private key(id_rsa) and a public key(id_rsa.pub).
$ ls
id_rsa.pub id_rsa
id_rsa.pub
is the pub key, and id_rsa is the private key.
2. Copy the public key to the Host B
Copy the content of id_rsa.pub
to Host B’s file: ~/.ssh/authorized_keys
or execute the following command on management host.
ssh-copy-id -i /root/.ssh/id_rsa.pub root@host_B
3. Set Appropriate Permission for file authorized_keys(Host B)
chmod 600 .ssh/authorized_keys
chmod 700 .ssh
4. Add Private Key to SSH Authentication Agent on Local Server(Host A)
$ cd .ssh
$ ssh-add id_rsa
Identity added: id_rsa (id_rsa)
# list added keys
$ ssh-add -l
5. Test (A –> B)
user@hostA $ ssh ubuntu@host_B