• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Tuesday, August 14, 2012

    How to create a password less ssh connection in Linux

    You can create a password less connection between two Linux box using RSA authentication. Before moving ahead with the steps to do so let us get to know RSA in brief.

    RSA and DSA are used as an algorithm for public-key encryption

    RSA and DSA keys are used for password authentication and providing much higher security for data transfer or connectivity between two remote machines.
    • RSA keys have minimum key length of 768 bits and the default length is 2048 bit.The key length of DSA is limited to 1024 bit so one can generate stronger RSA keys than DSA keys.
    • DSA encryption is faster as compared to RSA.
    • RSA can be used for both encryption and signing whereas DSA can only be used for signing.
    • RSA can be used with ssh v1 and v2 whereas DSA can only be used with v2
    For generating ssh key using RSA here are the steps to be followed:
    Server IP:
    Client IP:

    This command will generate a private(id_rsa) and a public(id_rsa.pub) key.

    NOTE: Make sure you give a blank password when prompted as shown with blue color below
    # ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    /root/.ssh/id_rsa already exists.
    Overwrite (y/n)? y
    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:
    The key's randomart image is:
    +--[ RSA 2048]----+
    |ooo .            |
    |B. + .           |
    |*++   .          |
    |== .   .         |
    |..o   . S        |
    | . . . o         |
    |  o . o     E    |
    | .     .   .     |
    |        ..o.     |
    Now we need to copy the public key to the remote machine between which you want the secure shell connection.

    Now copy the public key from the server machine to client (make sure the directories and files as mentioned exists on the client machine or else you will have to manually create them)

    NOTE: authorized_keys is a file and not a directory. Do no mistake it as a directory and copy id_rsa.pub inside it. In the below command we are copying and renaming the file id_rsa.pub into authorized_keys
    # scp /root/.ssh/id_rsa.pub
    On the client machine
    # chmod 600 /root/.ssh/authorized_keys
    # chmod 700 /root/.ssh

    Now restart the ssh services on the server and client machines
    # service sshd restart
    Stopping sshd:                                            
    [  OK  ]
    Starting sshd:                                            [  OK  ]

    Now try to connect your client server, you should be able to connect without password prompt
    # ssh 
    To change the RSA key
    # ssh-keygen -p

    Related Articles
    How to create password less ssh connection for multiple non-root users

    Follow the below links for more tutorials

    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    How to check all the currently running services in Linux
    How to auto start service after reboot in Linux
    What is virtual memory, paging and swap space?


    Post a Comment