Solving Global SSH Auth in Hyprland

Ansari
Category : Linux
Time to read : 3 mins
BTW am using arch recently and I’ve been hitting the wall lately that git works perfectly in my terminal, but fails in GUI apps like Obsidian, VScode etc..
This happens because Hyprland (Wayland) doesn’t load variables from .xprofile, and your GUI apps launch before your shell (zsh/bash) has a chance to tell them where your SSH Agent is.
Here is how I solved it with two lines of code, and why this method beats the complex Systemd approach.

The Problem: The Moving Target
By default, ssh-agent creates a random socket address (e.g., /tmp/ssh-XyZ123/agent.123).
- Hyprland launches: It has no idea where this socket will be.
- Obsidian launches: It inherits “nothing” from Hyprland.
- Terminal launches: You unlock keys, and a socket is created.
- Result: Your terminal works, but Obsidian is looking for a ghost.
The Solution: The Static Socket
We don’t need complex sync scripts. We just need to agree on a specific file path (a “Meeting Point”) that never changes.
1. Tell Hyprland where the meeting point is. Add this to ~/.config/hypr/hyprland.conf. Now, every app you launch knows exactly where to look for the key, even if the key isn't there yet.
env = SSH_AUTH_SOCK,$HOME/.ssh/agent.sock
2. Tell Keychain to use that specific meeting point. In your ~/.zshrc (or .bashrc), use the --ssh-agent-socket flag. This forces the agent to bind to that exact path we promised Hyprland.
eval "$(keychain -q --ssh-agent-socket $HOME/.ssh/agent.sock --eval 'YOUR_KEYS')"
Wait, what is this “Keychain” thing?
If you are wondering, “Did I just copy-paste bloatware?” , relax baba.
ssh-agent is basically a security guard with severe short-term memory loss. You open a terminal, he demands your ID (password). You open a new tab 10 seconds later, and he looks you dead in the eye and asks, "Who are you?" again.
keychain is the guy you hire to stand next to the guard. You show your ID once, and keychain tells the guard, "Chill, it's robin. He's cool." for the rest of the day. It is a tiny wrapper script (sudo pacman -S keychain) that keeps the agent alive and reuses it so you don't get repetitive strain injury from typing your password 50 times a day.
Why this is better than the Systemd method
Reference: Hyprland and SSH Agent by Lorenzo Bettini
Lorenzo’s article suggests the “Official” Linux way: creating a systemd --user service.
- The Systemd Way: Requires creating unit files (
.service), editing~/.config/environment.d/, and managing background daemons. It decouples the agent from your shell. - Keychain Way: No background services. No systemd unit files. No
dbus-update-activation-environmenthacks.