Server B need to access Server A using SSH Public Key authentication (Does not need to have password login)
At Server B
To use public keys with an ssh server, you’ll first need to generate a public/private key pair at Server A:
$ ssh-keygen -t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/home/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/root/.ssh/id_rsa. Your public key has been saved in /home/root/.ssh/id_rsa.pub. The key fingerprint is: a1:3c:a4:eb:18:95:1b:16:b1:a3:28:18:ga:81:3a:ba root@localhost
At Server B
To install the generated cert/key from Server B to Server A (or any server that ServerB need to access) with IP address 192.168.0.20 :
$ ssh 192.168.0.20 "mkdir .ssh; chmod 0700 .ssh" $ scp .ssh/id_rsa.pub 192.168.0.20:.ssh/authorized_keys2
By now, ServerB will be able to access ServerA without need to key in login password.
Alternative way of install cert from ServerB to ServerA
ssh-copy-id -i .ssh/id_rsa.pub root@serverA