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

5,387

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

Share:
5,387
FMaz008
Author by

FMaz008

Programmer for a couple of years, I enjoy learning new stuff and get involved in the open source community !

Updated on September 18, 2022

Comments

  • FMaz008
    FMaz008 over 1 year

    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?

    • Nathan Basanese
      Nathan Basanese over 8 years
      // , What if the machine doesn't even have the key in question? Can one specify which forwarded identity to use?
  • GLRoman
    GLRoman over 5 years
    advancing to the next roadblock: my ssh client then tries to update known_hosts and that fails!
  • Paul
    Paul over 5 years
    @GLRoman The UserKnownHostsFile option let's you specify where the file should be