Skip to content

Instantly share code, notes, and snippets.

@mvneves
Last active June 12, 2024 10:33
Show Gist options
  • Save mvneves/a6a69a53f039b3755900 to your computer and use it in GitHub Desktop.
Save mvneves/a6a69a53f039b3755900 to your computer and use it in GitHub Desktop.
"Could not open a connection to your authentication agent"

SSH authentication agent does not automatically start when using it from a remote server. This results in the following error message:

$ git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
$ ssh-add ~/my-ssh-key.pem
Could not open a connection to your authentication agent.

To fix it requires manually starting ssh-agent:

$ eval `ssh-agent -s`
Agent pid 13442
$ ssh-add ~/my-ssh-key.pem
Identity added: /home/user/my-ssh-key.pem (/home/user/my-ssh-key.pem)
$ git pull
@sanjay-io
Copy link

Thanks, this works with starting ssh-agent within Github Actions as well.

@Jkudjo
Copy link

Jkudjo commented May 11, 2022

this helped

@rikvermeer
Copy link

rikvermeer commented May 24, 2022

Nice hack with the eval, for the environment params. Will use it for sourcing exports (venv, esp-idf), thanks!
And it also fixed my problem... I was starting ssh-agent all over the place but it didn't wanna work in my yakuake/zsh.

@yogithesymbian
Copy link

thankyou !!!

@bruce1408
Copy link

it works

@Arshaddev389
Copy link

not working i still get that message could not open a connection to your authentication agent

@Gichunga
Copy link

thank you, it works

@donodanar35
Copy link

thanks

@grabbyel
Copy link

grabbyel commented Mar 6, 2023

great contribution!! Thanks!!

@RRRCHINO94
Copy link

fue de gran ayuda, gracias a mi me funcionó usando $ eval $(ssh-agent), seguro porque uso window 11

@prashant-kiit
Copy link

Thanks. It worked

@robisonweb
Copy link

I use Vs Code with Git bash integrated
Do you know how to make it so that when you open VS code it can execute these commands?

@RRRCHINO94
Copy link

RRRCHINO94 commented Oct 26, 2023 via email

@allwelldotdev
Copy link

Thanks. This worked for me like a charm. Thanks for explaining as well.

@kevin4052
Copy link

Thanks!

@Hoplite2A
Copy link

I am new to all of this and want to ensure I am understanding the syntax. The '~/my-ssh-key.pem' what is this value? Or do I use that in the CLI when attempting to rectify this overall issue?

@cchaduka
Copy link

I am new to all of this and want to ensure I am understanding the syntax. The '~/my-ssh-key.pem' what is this value? Or do I use that in the CLI when attempting to rectify this overall issue?

That is your SSH private key. Make sure you give the command ssh-add the correct path to where your private key is located on your filesystem. By default, this file is usually in the ~/.ssh/ directory and is called id_rsa or id_ed25519.

@AnandVishesh1301
Copy link

This came in clutch, Thanks!

@erias58
Copy link

erias58 commented May 4, 2024

SSH_AUTH_SOCK=/tmp/ssh-WvEP0dKfXLyl/agent.1753; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1754; export SSH_AGENT_PID;
echo Agent pid 1754;

if i try adding the key again
it returns "could not open connection to your authentication agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment