Create SSH Trust Connection Between Servers To Connect Without Password?
1. Generate a public and private key pair on the machine from where you want to login to other machines.
# ssh-keygen -t rsa1
For SSH2 (Recommended):
# ssh-keygen -t dsa
You will be prompted for a file in which the key and a passphrase will be saved. You may press Enter through each of these prompts. If you do so, the key generation program will assume that you wish to use the default file name of id_dsa and your private key will not be protected by a password.
Once this is done, you will see id_rsa and id_rsa.pub in the .ssh directory in your home directory if you have not supplied a file name as I mentioned above.
2. Copy the public keys (id_rsa.pub) to the remote host. This is the host(s) where you wanted to connect without password.
# scp ~/.ssh/id_rsa.pub remote_host:/
3. Login to the remote host and check if you already have authorized_keys file in .ssh dir. If this doesn’t exist, create it with the following commands.
# touch ~/.ssh/authorized_keys
- On the remote host where you are in step 3, copy your public key to the authorized_keys file, with the following command. (append only otherwise previous keys will be lost)
# cat ~/ id_rsa.pub >> ~/.ssh/authorized_keys
5. You are set to use SSH authentication without password now. If you want you can delete or move id_rsa.pub file.