简体   繁体   English

我可以在全球范围内(不是每个回购协议)在TortoiseGit中注册PuTTY密钥吗?

[英]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: 我熟悉使用TortoiseGit + PuTTY访问遥控器,您可以通过以下方式设置用于给定遥控器的PuTTY键:

  • the Remote node in the Settings windows 设置窗口中的远程节点
  • the .git\\config file... .git\\config文件...
[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. ...并获得Pageant集成的好处等等。

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. 但是,我们现在在共享位置\\\\server\\share\\myrepo共享一个临时\\\\server\\share\\myrepo ,以便任何团队成员都可以根据需要更新该\\\\server\\share\\myrepo This means that we can't store the puttykeyfile value in \\\\server\\share\\myrepo\\.git\\config , as it is unique per team member. 这意味着我们不能将puttykeyfile值存储在\\\\server\\share\\myrepo\\.git\\config ,因为该值对于每个团队成员都是唯一的。

Is it possible to define a "global" puttykeyfile in %USERPROFILE%\\.gitconfig or somewhere else that is user-specific rather than repo-specific? 是否可以在%USERPROFILE%\\.gitconfig或其他特定于用户而不是特定于回购的地方定义“全局” puttykeyfile

No need to edit .git/config by hand. 无需手动编辑.git/config There is the git config command which has options like --system , --global , and --local . git config命令,它具有--system ,-- --global--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". 也许您应该给上游/原始远程站点一个更好的名称,例如“ github”或“ gitlab”。 Then you can specify there a key for github and one for gitlab and everything should work fine. 然后,您可以为github指定一个密钥,为gitlab指定一个密钥,然后一切正常。

  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. 代替将腻子密钥文件存储在repo/.git/config ,可以通过发出git config --global remote.upstream.puttykeyfile path\\\\to\\\\key.ppk将其存储在%HOME%\\.gitconfig git config --global remote.upstream.puttykeyfile path\\\\to\\\\key.ppk ,其中upstream是您要使用密钥的遥控器的名称。

  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). 您也可以使用PuTTY会话在此处定义默认密钥(全局用于“默认连接”或特定的服务器名称,在PuTTY中的SSH-> Auth下称为会话)。 See https://tortoisegit.org/docs/tortoisegit/tgit-ssh-howto.html . 参见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. 或者,除了使用SSH之外,您还可以切换到https ,这些凭据存储在本地。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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