Linux - How to create password less login using ssh agent, How to use ssh-agent and ssh-add

How to create password less login using ssh agent

How to create login with no password ssh-agent?
what is ssh-agent?
ssh-agent is a background program that handles passwords for SSH private keys

What is ssh-add?
The ssh-add command prompts the user for a private key password and adds it to the list maintained by ssh-agent. Once you add a password to ssh-agent, you will not be prompted for it when using SSH or scp to connect to hosts with your public key.

Execute argument passed as shell command
 # eval `ssh-agent`
Your Output will look like below
 SSH_AUTH_SOCK=/tmp/ssh-xyzabc123/agent.1234; export SSH_AUTH_SOCK;
 SSH_AGENT_PID=4321; export SSH_AGENT_PID;
 echo Agent pid 4321;

Add your key to ssh Agent
 # ssh-add .ssh/id_rsa
OUTPUT
 Enter passphrase for id_rsa:
 Identity added: id_rsa (id_rsa)
Now check whether you are able to log into server without password.

To check you are able to log into server huge server list without password, you can simply make a test by using below.
 for linser in server1 server2 linux1 linux2 linux3 linux4 linux5
 do
   ssh $linser \"sleep 60\" &
 done

If success ssh-agent output will look like
  [1] 7156
  [2] 7157
  [3] 7158
  [4] 7159
  [5] 7160
  [6] 7161
  [7] 7162
  [8] 7163
  [9] 7164
  [10] 7165
  Warning: Permanently added \'linux1,xxx.xx.xx.xxx\' (RSA) to the list of known hosts.
  Warning: Permanently added \'linux2,xxx.xx.xx.xxx\' (RSA) to the list of known hosts.
  Warning: Permanently added \'linux3,xxx.xx.xx.xxx\' (RSA) to the list of known hosts.

If operation ssh-agent is failed then output will look like

[1]+ Stopped ssh linser \"sleep 60\"

[2] Stopped ssh linser \"sleep 60\"


To put you password agent permanently even after your logout
 # eval ssh-agent > my-pass-agent

 # vim .bashrc

Add as below in to your home .bashrc file
# Source global definitions
  if [ -f /home/linux/.bashrc ]; then
      . /home/linux/my-pass-agent &> /dev/null
  fi

Configure your ssh config file
 # vim .ssh/config 

  ConnectTimeout 3
  StrictHostKeyChecking no
  Compression yes
  ServerAliveInterval 30
  TCPKeepAlive yes
  User linux
  ConnectionAttempts 3

Warning: Enable forwarding only if it is necessary
 ForwardAgent yes
 ForwardX11 yes

To kill your ssh-agent simply do
  kill $SSH_AGENT_PID

The topic on Linux - How to create password less login using ssh agent is posted by - Guru

Hope you have enjoyed, Linux - How to create password less login using ssh agentThanks for your time

Tech Bluff