-->
🏠 🔍
SHAREOLITE

How to enable password less login using SSH keys - SSH equivalence

Have you ever wondered you can login to a server without entering any password ! Yes, it is possible - one such method is using SSH keys. Below procedure explains the steps how you can configure 2 servers to use SSH keys and enable password less login. This is also popularly known as SSH equivalence.

Execute below steps on the source machine : 

If ssh is not present, then please follow below steps.

         1) Open ssh version 2 or higher must be installed on both the machines.
            To check type this command on both the machines.

             % rpm -qa | grep ssh
               openssh-3.6.1p2-18
               openssh-askpass-3.6.1p2-18
               openssh-clients-3.6.1p2-18
               openssh-server-3.6.1p2-18
               openssh-askpass-gnome-3.6.1p2-18

         2) Check the version of ssh using command.

             % ssh -V

              OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
              Make sure you are using ssh protocol 2 version.

         3) Make sure the deamon process sshd is running on remote machine on
            which you want to login without  password.

            To check this, use following command

              % ps -ef | grep sshd
                root       884     1  0 May14 ?        00:00:02 /usr/sbin/sshd

         4) On the source machine , generate a pair of public/private key.

            1. Firstly create the directory .ssh under user directory for example under /home/testuser.

              Command : mkdir .ssh
              Command : chmod 700 .ssh
              Command : cd .ssh

            2. Generate your public/private keys using ssh-keygen as follows.

              Command : ssh-keygen -t dsa -f identity -b 1024

              When it prompts to enter a passphrase , simply provide blank by pressing Enter Keys

            3. Set permissions as give below.

              Command : chmod 600 identity
              Command : chmod 644 identity.pub
              Command : cat identity.pub    (Key would display in encypted form as below )
             
ssh-dss AAAB3NzaC1kc3MAAACBAPL2S6FCW42vkIJdHltmc+atf4bh7U4lPdugvnNumSy768AA7nPximbEGHBsFWtVTmJgXEUJ+V71Wz52LjVq9OKQRpBLbZukOSfrfQOc9+HdklQNNo0XEJsJK17ZWSMYy8OjsHf6d5W1uxl9i7Tlhw6rm9Ej3OZPSqodH9uHvKoVAAAAFQD/NT0Pyy30jopQuk93VW30nyr7XQAAAIEAqaVgEv1UWaPoWzc657DtHPvadlTyd+nBu5jQd3M04MfcV64875J1rSWoiZHtty1ASyP6JxbJvg0BZXVj2xpPfpg4wUpeUCEv3fFU39vVbdIIYCuYvHYAZn7208iNa8v/3bSCpIDwAZDeMd+REUDSK9OA7F6lJFgFfM59+MawNBcAAACBAIAvzJudzHbvqntwg27NQWt4106KiIjJ9/PenS+k1EjO1v3fdltVSruoHPTrS0IrXH2aurh8tWnKIu/QnvKURuolsn/ckuBbcg7qvUOLbVi9gRwU3hkXQLT46ExwxVeoWLFSS8vU4sDzWaPwj9zM2wXMlc/q0U5G8nwr/b9NQ4Or testuser@shareolite

Now on the remote server :

         a) Create the .ssh directory under /home/testuser2  if it does not exist

     Command : cd /home/testuser2
              Command : mkdir .ssh
              Command : chmod 700 .ssh
              Command : vi /home/testusers/.ssh/authorized_keys2
                        copy the contents of source machine identity.pub file
              Command : chmod 644 /home/testuser2/.ssh/authorized_keys2


Now from source machine if you execute the below command , you should be able to login without prompting for any password
ssh testuser2@remoteserverIP
Example : ssh testuser2@172.10.89.2

You can now execute commands on remote server using this method without entering any password as shown in below example
ssh testuser2@remoteserverIP "linux command"
Example : ssh testuser2@172.10.89.2 "date"

Hope this is useful sometimes.

Comments

–>