I just got gnome-keyring working with ssh and lazygit. Running hyprland and greetd. Here are my notes:
Check relevant environment variables. My vars look like this with the working config.
$ env | grep SSH
SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh
SSH_ASKPASS=
Make sure the remote connections’ URL starts with ssh instead of https:
git remote -v
If it isn’t set to ssh, set it to ssh with the following:
git remote set-url origin git@github.com:YOUR_GIHUB_USERNAME/YOUR_REPO_NAME.git
Start the ssh-agent in the background:
eval “$(ssh-agent -s)”
Agent pid 109777 #agent is running
Add your ssh private key to the ssh-agent:
ssh-add $HOME/.ssh/id_rsa
Add ssh-agent plugin to my bash/zsh:
plugins=(git ssh-agent)
Source the config:
source $HOME/.bashrc or $HOME/.zshrc
Nix Config
programs.seahorse.enable = true;
services.gnome.gnome-keyring.enable = true;
security.pam.services = {
greetd.enableGnomeKeyring = true;
greetd-password.enableGnomeKeyring = true;
login.enableGnomeKeyring = true;
};
};
services.dbus.packages = [ pkgs.gnome-keyring pkgs.gcr ];
Check if the daemon is running in btop/htop:
/run/wrappers/bin/gnome-keyring-daemon --start --foreground --components=secrets
Per reddit, if the daemon isn’t running, add the following:
services.xserver = {
displayManager.sessionCommands = ''
eval $(gnome-keyring-daemon --start --daemonize --components=ssh,secrets)
export SSH_AUTH_SOCK
'';
If the daemon is running, you may only need to add:
services.xserver = {
displayManager.sessionCommands = ''
export SSH_AUTH_SOCK
'';
You can also add eval $(/run/wrappers/bin/gnome-keyring-daemon --start --components=ssh)
to your shell init script or start it separately with a systemd user service.
Lastly, configure git per the wiki below. Also good to reboot before testing to make sure all your changer were loaded correctly. Good luck, brave traveler.
Useful links:
Guide to setup & restore ssh keys
NixOS Wiki: Git
Arch Wiki: SSH
Arch Wiki: gnome-keyring