Software⏱️ 2 min read📅 2026-05-31

How to Fix: ssh-add returns with: "Error connecting to agent: No such file or directory"

Check if SSH agent is running and add your private key to it.

Quick Answer: Run ssh-agent & then add your private key with ssh-add -L

The 'ssh-add' command is used to add a private key to the SSH agent, which allows you to use the key without having to enter the passphrase each time. However, if 'ssh-add' returns with an error message stating 'Error connecting to agent: No such file or directory', it means that the SSH agent cannot be found.

⚠️ Common Causes

  • There is no running SSH agent process.

🔧 Proven Troubleshooting Steps

Method 1: Start the SSH Agent

  1. Step 1: Check if an SSH agent is already running by using the command 'pgrep ssh-agent'. If it's not running, you can start it manually by typing '$ eval $(ssh-agent -s)' in your terminal.

Method 2: Use the SSH Agent with 'ssh-add' Options

  1. Step 1: Use the '-A' option to add the private key without starting a new SSH agent process. The command would be '$ ssh-add -A '.

💡 Conclusion

By following these steps, you should be able to resolve the 'ssh-add' error and successfully add your private key to the SSH agent.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions