Tuesday, 21 April 2015

SSH Passwordless Login Using SSH Keygen

SSH Passwordless Login Using SSH Keygen in 5 Easy Steps

    If you want to sent a secret message to remort mechine, the you need to know the remort mechine's public key after that you need to encrypt that message using the remort mechines's public key after that sent the message to remort mehine. After receiving the message the remort mechine decrypt the message with its private key.

In this example we will setup SSH password-less automatic login from server as user anusree to with user anusree.

step 1: Create Authentication SSH-Kegen Keys on – (
    anusree@anusree-Inspiron-5547:~$ ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/anusree/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/anusree/.ssh/id_rsa.
    Your public key has been saved in /home/anusree/.ssh/id_rsa.pub.
    The key fingerprint is:
    The key's randomart image is:
    +--[ RSA 2048]----+
    | .+ oo..oo.      |
    | . o o+= .E      |
    |    ..o = .      |
    |       * o       |
    |      + S o      |
    |     . * . .     |
    |      . .        |
    |                 |
    |                 |
    First login into server with user anusree and generate a pair of public keys using following command.

This will create the public key and also privet key, public key is save in /home/anusree/.ssh/id_rsa.pub, and private key is saved in /home/anusree/.ssh/id_rsa.

Step 2: Create .ssh Directory on –   ------------>   Use SSH from server to connect server using anusree as user and create .ssh directory under it, using following command.

 anusree@anusree-Inspiron-5547:~$ ssh anusree@ mkdir -p .ssh
 anusree@'s password: [Enter Your Password Here]

step 3: Upload Generated Public Keys to –  ----------->   Use SSH from server and upload new generated public key (id_rsa.pub) on server under anusree‘s .ssh directory as a file name authorized_keys.

 anusree@anusree-Inspiron-5547:~$ cat .ssh/id_rsa.pub | ssh anusree@ 'cat >> .ssh/authorized_keys'
anusree@'s password: [Enter Your Password Here]

Step 4: Set Permissions on –
     --------->  (optional)

        Due to different SSH versions on servers, we need to set permissions on .ssh directory and authorized_keys file.

 anusree@anusree-Inspiron-5547:~$ ssh anusree@ "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
    sheena@'s password: [Enter Your Password Here]

Step 5: Login from to Server without Password

      From now onwards you can log into as anusree user from   server as anusree user without password.

anusree@anusree-Inspiron-5547:~$ ssh anusree@
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)

* Documentation:  https://help.ubuntu.com/

Last login: Wed Apr 22 00:09:10 2015 from