Friday, November 26, 2010

SSH Configuration between servers

SSH Configuration between linux servers without giving password

SSH can give you authenticated and encrypted connections to remote computers. If you set up keys you can make these connections without passwords.

I test this for RHEL5 64 bit OS

Step1: Generate a public and private key pair on the machine from where you want to login to other machines.

For SSH1:
# ssh-keygen -b 1024 -t rsa
For SSH2 (Recommended):
# ssh-keygen -b 1024 -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 file in the .ssh directory in your home directory if you have not supplied a file name as I mentioned above.

Step 2: Copy the content of id_rsa.pub file to authorized_keys2 file available in .ssh directory of the remote host(s)
  • Copy the public keys (id_rsa.pub) to the remote host. That is the content of id_rsa.pub file to the file called  authorized_keys2 available in .ssh directory of the host(s) where you wanted to connect without password. 
  • Be aware that .ssh directory will be available in the home directory as hidden file so make sure it availability by ls -ltr command in the home directory.
# scp ~/.ssh/id_rsa.pub remote_host:/

Step 3: Login to the remote host and check if you already have authorized_keys2 file in .ssh dir. If this doesn’t exist, create it with the following commands.

# touch ~/.ssh/authorized_keys2

Step 4: On the remote host where you are in step 3, copy your public key to the authorized_keys2 file, with the following command.

# cat ~/ id_rsa.pub >> ~/.ssh/authorized_keys2

Step 5: You are set to use SSH authentication without password now. If you want you can delete or move id_rsa.pub file.

You can follow steps 2 – 5 for all other hosts where you want to have public key authentication.


SSH Configuration between serversSocialTwist Tell-a-Friend

No comments:

Post a Comment