The Missing Bit

Fix keychain ssh-agent helper with fish
2023-10-25

fish ssh linux

I use keychain from funtoo which helps re-using ssh-agent.

But I had an isssue from time to time, the $SSH_AUTH_SOCK would be unset.

It seems there is an issue with Universal fish variable which keychain uses.

The workaround is to copy those variables to global ones, like so in your config.fish.


if status --is-interactive
    keychain --agents ssh --eval --quiet --inherit any -Q | source
    # Make those variables global to avoid universal version override
    set -xg SSH_AUTH_SOCK $SSH_AUTH_SOCK
    set -xg SSH_AGENT_PID $SSH_AGENT_PID
end

This ensure that setting those variables in other terminals will not mess them up.

If you wish to comment or discuss this post, just mention me on Bluesky or