Saturday, June 17, 2023

SSH Agent

To Start the ssh-agent on opening new terminal (Linux or WSL2).

Add following lines to ~/.bash_aliases

 
export SSH_AUTH_SOCK="${HOME}/.ssh/ssh-agent.sock"
ssh-add ~/keys/git-rsa
 
if [ $? -ge 2 ];then
    ssh-agent -a ${SSH_AUTH_SOCK}
    ssh-add ~/keys/git-rsa
fi

It will start the ssh-agent if it is not already running or else connect to existing ssh-agent for new terminal.