Flipkart

Wednesday, October 29, 2014

Login Without Password using ssh-keygen & ssh-copy-id

Below are the steps to Login into Remote server without entering password using SSH commands: Step 1: Generate the Public and Private keys using below command:
faruq@local-sys:/tmp# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
2c:17:97:ce:ab:ef:9e:9f:33:e5:46:67:e7:9c:53:7e root@innopark-HP
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|           .     |
|        . o      |
|       . =       |
|      . S o      |
|       o   .  o =|
|          .  + *+|
|         . .o.ooE|
|        .+=.o+  o|
+-----------------+
Step 2: Copy the Local public key to remote server using ssh-copy-id
faruq@local-sys:/tmp# ssh-copy-id root@<remote-ip>
         root@<remote-ip>'s password: 

         Number of key(s) added: 1 

        Now try logging into the machine, with: "ssh 'root@<remote-ip> '" and check to make     sure that only the key(s) you wanted were added.
Thats it, From next time it will not ask for password to authenticate