How do I make git credential-osxkeychain work correctly when I'm connected to a machine via SSH? I setup a build machine to check out sources from Github by caching the login credential in the keychain using instructions from: https://help.github.com/articles/caching-your-github-password-in-git/

Using SSH to connect to the build machine and run the instructions provided fails silently, asking me for a password for each git clone command.

Using VNC to connect to the build machine and run the instructions provided prompts me the first time, as expected, but not for any subsequent git clone commands, and successfully adds the credential to the keychain.

How can I configure the credential helper and/or keychain to make this work over SSH without a VNC connection?
You can use ForwardAgent option in ~/.ssh/config, if it is allowed on server by option AllowAgentForwarding (in sshd_config).

Or just simply with a switch -A to ssh. It will forward connection to your agent to the server and you will be able to authenticate to github.