Question

Let me start by stating the obvious ... my confidence with git is still cowering off in a dark corner :)
We've been using it here in-house lately, and I'm starting to get the hang of it, but I've got a few more hours to put in before I get my license ;)

We have a repository within our intranet, and when using the git-cmd cli, git looks for the default key in the default location when trying to authenticate.
Our repository is using a different key.

Is there a git config file or something that I can edit to put in the path to the proper key?
How do I set the credentials?

Was it helpful?

Solution

Short answer

If you are accessing the repository over HTTPS, then you can use the http.sslKey configuration or the GIT_SSL_KEY environment variable to specify its location (see the git config docs).

Long answer

Usually it doesn't matter where your private keys are, because ideally they are stored in a key agent, and what you need to figure out is how to make Git use the key agent.

(The thing is, ideally a private should have a passphrase, and so re-entering it every time would not be practical. The key agent is to simplify this.)

Since everyone should be using private keys protected by a passphrase, and thus a key agent to make that practical, it is not common to have to configure the location of the key file.

In windows I use pageant as the key agent, which is part of the PuTTY tools. Simply run pageant.exe and add your private key. Next, to make Git use pageant to get your private key, you need to set the GIT_SSH environment variable to point to plink.exe, for example /c/path/to/putty/plink.exe. You can set it like this in your environment variables, even though it uses UNIX-style path separators.

I am not familiar with TortoiseGit, but I guess it probably has it's own plink.exe, you can use that too. And since you already have TortoiseGit working, I guess you might not even need the key agent at all, just set GIT_SSH. But these are just guesses. The setup I described with PuTTY and pagent should work, as I use it myself. In any case you should use a key agent, and protect your keys with a passphrase, etc etc etc.

OTHER TIPS

Generating SSH Keys

# Creates a new ssh key using the provided email
ssh-keygen -t rsa -C "your_email@example.com"

GitHub user to be the committer when I do a local commit?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top