I'm connected to serverA with SSH. I have one identity file on my local computer, which I use to authenticate to serverA, and one identity file on serverA which I use when I'm at that computer physically. I have ForwardAgent yes in my local ssh config file.
Now, from serverA, I'm trying to open another ssh session to serverB. However, SSH will then try to use the identity file on serverA to connect to serverB, but I would like to use the identity file on my local computer (forwarded using ForwardAgent).
How can I tell SSH on serverA to use the keys forwarded, instead of the keys on serverA, when I am connected to serverA through SSH?
Answer: The problem, it turned out, was that my local computer was running macOS, which does not add keys to the agent by default. Therefore, no keys were forwarded to serverA. After adding AddKeysToAgent yes as well as ForwardAgent yes to my local config, ssh on the remote linux machine uses the forwarded key instead of the remote key by default. So no changes had to be made to the remote machine.