ssh-add – Could not open a connection to your authentication agent

When working with gitlab, to push our source code server we need to add the SSH key from our machine to gitlab.. while doing so, we may face some errors / warnings in setup.. one such error can be seen when try to add SSH key to OpenSSH authentication agent using “ssh-add” command.

$ ssh-add /home/myuser/.ssh/id_rsa.pub
Could not open a connection to your authentication agent

Solution :

This error can be visible when we are working on newly installed Ubuntu and authentication agent is not running, so we have to start the agent using below command,

$ ssh-agent -s

The output of above command on terminal would be as below,

$ ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-AxTnx3bEYBhS/agent.78523; export SSH_AUTH_SOCK;
SSH_AGENT_PID=78524; export SSH_AGENT_PID;
echo Agent pid 78524;

Now, if we check that agent is already running as,

$ ps -A | grep 78524
  78524 ?        00:00:00 ssh-agent

Now, if we try to add ssh key again then it will work as,

$ ssh-add /home/myuser/.ssh/id_rsa.pub

Leave a Comment