Tell git which private key to use for a user without home folder

I was reading the question Tell git which private key to use, and the answer doesn't apply for a case were the user doesn't have any home directory.

We're setting up a Jenkins server right now, and the user who run Jenkins doesn't have any home folder. But that particular user must access a GIT repository.

How can the user running GIT use a key authentication?


The environment variable GIT_SSH tells git what ssh exectutable to use. So you could create a script something like:

#!/bin/bash
/usr/bin/ssh -i /path/to/identity.file "$@"

Then chmod it executable, and set GIT_SSH=/path/to/sshscript