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

9

2

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?

FMaz008

Posted 2011-11-09T21:22:46.670

Reputation: 203

// , What if the machine doesn't even have the key in question? Can one specify which forwarded identity to use? – Nathan Basanese – 2015-09-11T19:37:33.937

Answers

14

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

Paul

Posted 2011-11-09T21:22:46.670

Reputation: 52 173

advancing to the next roadblock: my ssh client then tries to update known_hosts and that fails! – GLRoman – 2018-08-29T21:41:59.690

1@GLRoman The UserKnownHostsFile option let's you specify where the file should be – Paul – 2018-08-29T22:09:42.720