Tsiruan
Tsiruan

Reputation: 23

ssh-agent: Could not open a connection to your authentication agent

I have done a ton of research already, but none of those works. This is output from my terminal:

$ ps aux | grep ssh-agent
tsiruan   4080  0.0  0.0  13468   388 ?        Ss   11:47   0:00 ssh-agent
$ env | grep SSH
SSH_AUTH_SOCK=/tmp/ssh-8CJH68abyLAa/agent.4079
SSH_AGENT_PID=4080
$ sudo ssh-add .ssh/bitbucket_ssh
[sudo] password for tsiruan:
Could not open a connection to your authentication agent.

I have tried $ eval $(ssh-agent) with backticks, single quote, double quote, with and without parentheses, with and without -s option, and even some answers like:

$ exec ssh-agent bash

please help me , I am running bash on arch linux.

Upvotes: 2

Views: 18729

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295272

First Choice: Don't Use sudo

ssh-add .ssh/bitbucket_ssh

Second Choice: Pass The Environment Variable Explicitly

Assuming your bitbucket_ssh file is only readable by root -- the more appropriate approach is to fix the permissions, but as an interim approach, you can pass SSH_AUTH_SOCK through:

sudo env SSH_AUTH_SOCK="$SSH_AUTH_SOCK" ssh-add .ssh/bitbucket_ssh

Upvotes: 6

Related Questions