Skip to content
nerdsid_
  • Posts
  • Journal

Navigation

  • Posts
  • Journal
Posts

How to fix SSH error: Could not open a connection to your authentication agent

Updated: 07 Jan 2023

The problem

Recently, I was trying to add a SSH key to the ssh-agent. So, I ran the following command:

Bash
ssh-add ~/.ssh/<key_name>

This resulted in the following error:

Bash
Could not open a connection to your authentication agent.

The solution

The error message is pretty clear. Since a connection to the ssh-agent could not be opened, first let’s check if the ssh-agent is running or not.

Bash
ps -e | grep [s]sh-agent

If the ssh-agent is not running, you will not see any output. This is exactly what happened in my case. So, the solution is simple: you need to start the ssh-agent.

You just need to run the following command to start the ssh-agent.

Bash
eval "$(ssh-agent -s)"

This should result in an output similar to the following.

Bash
Agent pid 59566

Now, you can try addding an SSH key to the ssh-agent.

Bash
ssh-add ~/.ssh/<key_name>

In my case, the key was added successfully.

Bash
Identity added: /home/user/.ssh/<key_name> (/home/user/.ssh/<key_name>)

Conclusion

To fix the ssh error: Could not open a connection to your authentication agent, you just need to start the ssh-agent.

Tags: linux ssh troubleshooting … views

Keep reading

  • 11 essential OpenSSH components
  • 10 steps to secure a new Linux VM
  • One line command to create an SSH key
  • Setup SSH authentication for Git on Windows

  • Home
  • Posts
  • Journal
  • Labs
  • Snippets
  • Quotes
  • Links worth your time
  • About
  • Contact
  • Style guide
  • RSS

© 2026 Sidharth R. · Licensed CC BY-NC-SA 4.0