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 agentHow 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_rsaOUTPUT
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
 7156  7157  7158  7159  7160  7161  7162  7163  7164  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
+ Stopped ssh linser \"sleep 60\"
 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
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