For a long time I've wondered why when I use ssh on MacOS I need to use
ssh-add to add keys to the ssh agent, whereas when I use ssh on Fedora I don't. The agent seems to automatically load keys in my ~/.ssh/ directory. The question pops up from time to time, and I usually research a little until I uncover something new, and satisfy my curiosity.
Some time ago I set up a Fedora server locally, and noticed that there I had to use
ssh-add too. At the time I decided to create a config file where I specify the identity file for the only host I connect to, which is github.
Some time later I saw the same behavior on a remote server I set up on rackspace. This server uses fedora as well. However, on that server I need to start the ssh agent, as well as manually add the keys to it every time I want to use ssh to connect to github. For some reason I never set up a config file there, and today I had another one of those moments where I just want to figure everything out.
I think today's been one of the longest research sessions. On my previous research session I learned that Gnome, or more accurately X, starts the ssh agent, and adds keys to it. At that time that was enough to satisfy my curiosity, but today I really wanted to figure out how it does that, and why MacOS does not.
I spent some time reading the Xsession script, and the scripts that it includes as it is executed, and I confirmed what I had read on some sources: X starts the ssh agent and passes the gnome session script to it. So, basically I confirmed what I learned before about X starting the ssh agent. This is the reason I have to manually start the agent in the rackspace server, because that does not run X. I guess the local Fedora server does it's own set up at start time to run the ssh agent, but I haven't looked into that.
However, it wasn't very clear to me how the Fedora ssh agent got a hold of the existing ssh keys, while the MacOS agent does not. I assumed both OSes used the same ssh-agent from OpenSSH, but at this point I'm thinking they do not.
Reading this question Adding SSH keys to ssh-agent on demand I saw that the single answer there mentions that an agent may do something fancy to add keys to the agent beforehand. And it goes on to specifically mention that a desktop environment implementation may have keys in some wallet. This made me think gnome has its own agent implementation.
At this point I want to make a parenthesis to mention that in MacOS I've added a key to my local fedora server to the keychain, and this effectively loads the key in the ssh agent, and unlocks it. I did this some time ago, and it made me think that Fedora was doing something similar, where it had keys in some kind of keychain, and it was loading them that way, so today I started looking into some type of keychain in fedora. I eventually learned about gnome-keyring. Also, the question I linked above mentions gnome-keyring-daemon, and how it launches an ssh-agent
Back to today's research, I started looking into the gnome source. Specifically, the gnome-keyring project. In that project there is an ssh-agent, that seems to have pre-loading functionality for keys (https://gitlab.gnome.org/GNOME/gnome-keyring/-/tree/master/daemon/ssh-agent). This is where my question arises: Does gnome have it's own
ssh-agent implementation, and that is what Fedora uses? And if that is the case, what happens to the OpenSSH implementation in Fedora systems?
UPDATE: Yesterday, after posting this question I learned my Fedora system (desktop, not server) is actually using Wayland. I had seen in the about section of the settings that the Windowing system was set to Wayland before, but it wasn't clear to me that this meant X was not being used. This may be obvious to many, but I'm not an expert on any of this. It would also seem that Wayland is not starting the ssh-agent in the same way X does, but rather on demand when it is actually first needed (How do I set a default ssh-agent timeout under Gnome).
It's also been pointed in the comments that my question may be a bit pointless, but I want to get confirmation of my suspicions from someone who actually knows, and understands the inner workings of fedora and ssh-agent precisely because I'm not an expert, and I don't want to just accept my possibly wrong/incomplete findings.