简体   繁体   中英

Can I register a PuTTY key with TortoiseGit globally (not per repo)?

I am familiar with using TortoiseGit + PuTTY to access a remote, you can set the PuTTY key used for a given remote via:

  • the Remote node in the Settings windows
  • the .git\\config file...
[remote "upstream"]
url = git@gitlab.com:name/project.git
fetch = +refs/heads/*:refs/remotes/upstream/*
puttykeyfile = C:\\Users\\name\\Documents\\key.ppk

...and get the benefits of Pageant integration and so on.

This works as expected in a local development environment. However, we are now sharing a staging repo in a shared location \\\\server\\share\\myrepo , so that any team member can update that repo as required. This means that we can't store the puttykeyfile value in \\\\server\\share\\myrepo\\.git\\config , as it is unique per team member.

Is it possible to define a "global" puttykeyfile in %USERPROFILE%\\.gitconfig or somewhere else that is user-specific rather than repo-specific?

No need to edit .git/config by hand. There is the git config command which has options like --system , --global , and --local .

  • "local" means "set for that repository".
  • "global" means "set for all repositories of that user".
  • "system" means "set fol all users of that computer".

Therefore you can set your value by something like:

git config --global remote.upstream.puttykeyfile C:\\Users\\name\\Documents\\key.ppk

However (as you see above) the keyfile is configured per remote. Maybe you should give your upstream/origin remote a better name like "github" or "gitlab". Then you can specify there a key for github and one for gitlab and everything should work fine.

  1. Instead of storing the putty key file in repo/.git/config it can be stored in %HOME%\\.gitconfig by issuing git config --global remote.upstream.puttykeyfile path\\\\to\\\\key.ppk , where upstream is the name of the remote you want to use the key for.

  2. You can also use PuTTY sessions in order to define a default key there (globally for "Default connection" or for specific servernames called sessions under SSH->Auth in PuTTY). See https://tortoisegit.org/docs/tortoisegit/tgit-ssh-howto.html .

  3. Or, instead of using SSH you could also switch to https , those credentials are stored locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM