Brain bin 🧠🗑️

Gnome/Keyring does not wraps around SSH Agent automatically

It seems that starting from version 1:46.0-1, the gnome-keyring changed it's behavior and now it disables building the ssh-agent support by default.

The OS by default also doesn't enable it, which was the cause for all my ssh-agents goes missing every time I tried to do any connection and even asking for password again.

Looking at the Gitlab MR, it seems like we're now supposed to use gcr-ssh-agent. Here's the instructions:

  1. Run: systemctl enable --user gcr-ssh-agent.socket to enable the socket.
  2. Set: $SSH_AUTH_SOCK environment value to $XDG_RUNTIME_DIR/gcr/ssh. I just put this in my .zshrc:
    1. export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh
  3. Reboot

After those two changes, your SSH keys should start working just like before.


Other workaround I was doing before finding those threads were adding this to my .zshrc:

if [ -z "$SSH_AUTH_SOCK" ]; then
  eval "$(ssh-agent -s)" > /dev/null
  ssh-add ~/.ssh/id_ed25519_github &> /dev/null
  ssh-add ~/.ssh/id_ed25519_gitlab &> /dev/null
fi

The problem with this approach is that it will init a new ssh-agent for every newly created console session since the .zshrc will be loaded every time. But since it was a workaround, I didn't care. It was more stressful not to have it working at all.

References

#gnome #linux #ssh