Admin-Ahead Community

Linux => General Linux => Topic started by: aneeshs on May 20, 2017, 09:34:07 pm

Title: Password less SSH login to server
Post by: aneeshs on May 20, 2017, 09:34:07 pm
By using the ssh-keygen command, we can generate public and private key pairs, which can be used for password less SSH login to a server.

First you have to generate the keys from the server to which you need the password less login.

1. Login to the server
   #ssh root@server

2. Generate the key
   #ssh-keygen -t rsa

By default, the keys id_rsa (private key) and id_rsa.pub(public key) will be generated to the directory ~/.ssh

3. Move to the .ssh directory
   #cd .ssh

4. Add the public key to SSH authorized_keys file
   #cat id_rsa.pub >> authorized_keys

5. Modify the permission of authorized_keys file for privacy purposes
   #chmod 600 authorized_keys

6. Delete the public key from the server
   #rm id_rsa.pub

Now we have to configure the client side

1. Move to the .ssh directory
   #cd .ssh

2. Copy the private key from the server to the client machine
   #scp root@server:.ssh/id_rsa .

Once this is done, you will be able to login to the remote server via SSH without the password authentication from the client machine.