22

I type in ssh-agent and get the following back:

SSH_AUTH_SOCK=/tmp/ssh-GqdeT074HLRJ/agent.4670; export SSH_AUTH_SOCK;
SSH_AGENT_ID=4671; export SSH_AGENT_PID;
echo Agent pid 4671;

I then type in ssh-add privkey.pem and get the following:

Could not open a connection to your authentication agent

Any ideas as to what I'm doing wrong? I tried adding sudo before each of those commands, as well, but got near identical output.

Giacomo1968
  • 58,727
neubert
  • 7,574
  • 39
  • 94
  • 156

3 Answers3

30

You’re supposed to execute the output that you get back from ssh-agent, like this: eval $(ssh-agent)

Then your environment is set up for ssh-add to connect to the agent.

3

You may also use the following syntax:

ssh-agent sh -c 'ssh-add && echo Do some stuff here.'
kenorb
  • 26,615
-1

I found solution:

run below command OR add to .bashrc file

exec ssh-agent bash

ssh-add [key path]