0

The ssh-agent service is enabled for the user and is running without errors. (status is active).
But when I try to use ssh, I get the error Could not open a connection to your authentication agent.. I don't understand why this is happening. Earlier ssh used to work right away and I could connect to the server via my key, but now I wanted to connect and I get the error Permission denied (public key), then I tried to add it via ssh-add and I get this.
enter image description here

I googled how to fix it, and found a solution eval $(ssh-agent -s), but it only works for bash, and I'm using fish, and there I googled that you have to set environment variables manually, and then you have to do it every time, it used to work. I googled how to get it to run on its own, and googled that I need to enable the ssh-agent daemon, but I already enabled it and it works, but the error is still there, even if I run bash, same error.

System: Arch linux

2 Answers 2

1

I googled how to fix it, and found a solution eval $(ssh-agent -s), but it only works for bash, and I'm using fish

That does not apply here; that's the command to start a new instance of ssh-agent (and more importantly, to set environment variables that ssh-agent outputs when started).

Focus on the semantics of the command before the syntax; if the command does the right thing then you can adapt its syntax to any shell.

and there I googled that you have to set environment variables manually, and then you have to do it every time

You do indeed have to do it every time.

The .service provided by Arch Linux doesn't have any options that would allow ssh-agent to set environment variables for the entire user (it has PassEnvironment=, which actually works in the opposite direction than what the package maintainer thought it does, so in this case it does nothing at all), and systemd doesn't even have a generic mechanism that would allow that.

So the only way to use this service is to manually set SSH_AUTH_SOCK through your login scripts (e.g. through ~/.bashrc or ~/.profile).

it used to work

You were probably using something different, such as GNOME Keyring (which has a PAM module that allows it to automatically set the ssh-agent environment variables at login time) or pam_ssh (likewise).

2
  • That functionality was moved from gnome-keyring to gcr (i.e. gcr-ssh-agent.socket), but for some reason they moved gnome-keyring 46 to the main repository even though the rest of GNOME 46 is still waiting in testing. Wait for gcr-4 version 4.2.1 and then enable gcr-ssh-agent.socket. Mar 2 at 20:04
  • Thank you very much. I think it has something to do with my comment, I deleted it as I thought I might have missed something :) Mar 2 at 21:51
1

You basically have two options:

  1. Use the -c flag: eval (ssh-agent -c)
  2. Use keychain instead

Source

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .