I am familiar with using TortoiseGit + PuTTY to access a remote, you can set the PuTTY key used for a given remote via:
.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
.
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.
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.
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 .
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.