Ssh agent not starting

I have the following in my /etc/nixos/configuration.nix,

  programs.ssh.startAgent = true;

run nixos-rebuild --upgrade switch, and rebooted, but ssh-add complains Error connecting to agent: No such file or directory. Is there something more I need to be doing to make this take effect?

It turns out I had a leftover ssh-agent.service file in ~/.config/systemd/user/ that got copied over from my previous system, which was interfering. Removing that file (and running systemctl --user daemon-reload) resolves the problem.

2 Likes