git Tortoisegit 询问密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8846972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:44:14  来源:igfitidea点击:

Tortoisegit asking password

gitversion-controltortoisegit

提问by pramodtech

I just started to work on Git. I use windows 7 and has installed msysgit(1.7.8) and Tortoisegit(1.7.6). The repository is created on Linux server which is accessible thru LAN. The issue I'm facing is I'm not able to clone the repository using Tortoisegit, it asks for password and I'm not sure what password it is asking. At the same time I could clone the repository using Git Gui and do all operations. Can anybody please help me on understanding why Tortoisegit is asking password when Git Gui doesn't. I tried uninstalling Git and Tortoisegit and then install again but no success.

我刚刚开始研究 Git。我使用 Windows 7 并安装了 msysgit(1.7.8) 和 Tortoisegit(1.7.6)。该存储库是在可通过 LAN 访问的 Linux 服务器上创建的。我面临的问题是我无法使用 Tortoisegit 克隆存储库,它要求输入密码,但我不确定它要求输入什么密码。同时我可以使用 Git Gui 克隆存储库并执行所有操作。任何人都可以帮助我理解为什么 Tortoisegit 在 Git Gui 没有询问密码的情况下询问密码。我尝试卸载 Git 和 Tortoisegit,然后再次安装但没有成功。

Tortoisegit error

龟毛错误

回答by pramodtech

My colleague solved the problem. Steps:

我的同事解决了这个问题。脚步:

  1. Right click -> TortoiseGit -> Settings -> Network
  2. SSH client was pointing to C:\Program Files\TortoiseGit\bin\TortoisePlink.exe
  3. Changed path to C:\Program Files (x86)\Git\bin\ssh.exe
  1. 右键单击 -> TortoiseGit -> 设置 -> 网络
  2. SSH 客户端指向 C:\Program Files\TortoiseGit\bin\TortoisePlink.exe
  3. 将路径更改为 C:\Program Files (x86)\Git\bin\ssh.exe

Alternative Path: C:\Users\...\AppData\Local\Programs\Git\usr\bin\ssh.exe

替代路径: C:\Users\...\AppData\Local\Programs\Git\usr\bin\ssh.exe

回答by BlueRaja - Danny Pflughoeft

If you need to use a username/password, there is a much simpler solution than the current #2 answer:

如果您需要使用用户名/密码,有一个比当前 #2 答案更简单的解决方案:

Right-click --> Tortoise Git --> Settings --> Git --> Credential --> Choose "Wincred, all Windows users" --> Hit apply

Right-click --> Tortoise Git --> Settings --> Git --> Credential --> Choose "Wincred, all Windows users" --> Hit apply

The next time you enter the password for a repo, that password will be automatically saved.

下次输入回购密码时,该密码将自动保存。



If you're using a repository that requires SSH keys rather than username/password (which it sounds like was OP's original issue), you need to

如果您使用的存储库需要 SSH 密钥而不是用户名/密码(这听起来像是 OP 的原始问题),您需要

  1. Open the SSH key in PuTTY gen (installs itself alongside Tortoise Git)
  2. In PuTTY gen, save the key as a PuTTY key.
  3. In the repository, Right-click --> Tortoise Git --> Settings --> Git --> Remotes. Find your remote (usually 'origin')then load the PuTTY key from step 2.
  1. 在 PuTTY gen 中打开 SSH 密钥(与 Tortoise Git 一起安装)
  2. 在 PuTTY gen 中,将密钥保存为 PuTTY 密钥。
  3. 在存储库中,Right-click --> Tortoise Git --> Settings --> Git --> Remotes. 找到您的遥控器(通常是“origin”),然后从第 2 步加载 PuTTY 密钥。

回答by Hugh Fuve

To do it without keys...

在没有钥匙的情况下做到这一点......

Right click on your folder
Select tortoiseGit->settings->Git->Remote
Select origin (or whatever you have labeled your main remote)

右键单击您的文件夹
选择 tortoiseGit->settings->Git->Remote
选择来源(或您标记的主遥控器)

Under URL use this format.

在 URL 下使用此格式。

Https://USERNAME:PASSWORD@URL

Where USERNAME is your username
: the colon separates username and password and must be there
PASSWORD is your password
@ separates credentials with your url
URL is the url you would use to connect to the .git resource

Thanks goes to Kamaci

其中 USERNAME 是您的用户名
:冒号分隔用户名和密码,并且必须存在
PASSWORD 是您的密码
@ 将凭据与您的 url 分开
URL 是您用来连接到 .git 资源的 url

感谢 Kamaci

回答by Anthony Keane

Saving username and password with TortoiseGit

使用 TortoiseGit 保存用户名和密码

Saving your login details in TortoiseGit is pretty easy. Saves having to type in your username and password every time you do a pull or push.

在 TortoiseGit 中保存您的登录详细信息非常简单。每次执行拉取或推送时都不必输入用户名和密码。

  1. Create a file called _netrc with the following contents:

    machine github.com
    login yourlogin
    password yourpassword

  2. Copy the file to C:\Users\ (or another location; this just happens to be where I've put it)

  3. Go to command prompt, type setx home C:\Users\

  1. 创建一个名为 _netrc 的文件,内容如下:

    机器 github.com
    登录 yourlogin
    密码yourpassword

  2. 将文件复制到 C:\Users\(或其他位置;这恰好是我放置它的位置)

  3. 转到命令提示符,键入 setx home C:\Users\

Note: if you're using something earlier than Windows 7, the setx command may not work for you. Use set instead and add the home environment variable to Windows using via the Advanced Settings under My Computer.

注意:如果您使用的是早于 Windows 7 的版本,则 setx 命令可能不适合您。改用 set 并通过“我的电脑”下的“高级设置”将家庭环境变量添加到 Windows。

CREDIT TO: http://www.munsplace.com/blog/2012/07/27/saving-username-and-password-with-tortoisegit/

信用:http: //www.munsplace.com/blog/2012/07/27/saving-username-and-password-with-tortoisegit/

回答by mzzzzb

One way to do this is

一种方法是

  • generate a keypair using PuttyGen, (or import into .ppk if you already have a key)
  • load the private key to peagent
  • import public key to you gitosis server (supply your public key to your admin)
  • and then use plink as SSH client
  • 使用 PuttyGen 生成密钥对(如果您已经有密钥,则导入到 .ppk 中)
  • 将私钥加载到peagent
  • 将公钥导入您的 gitosis 服务器(将您的公钥提供给您的管理员)
  • 然后使用 plink 作为 SSH 客户端

plink works natively with peagent to retrieve the loaded key.

plink 与 peagent 本地工作以检索加载的密钥。

you can find plink.exe along with peagent and other goodies in standard putty distribution

您可以在标准腻子发行版中找到 plink.exe 以及 peagent 和其他好东西

to use it go to:

使用它去:

TortoiseGit Settings -> Network -> SSH client .

TortoiseGit 设置 -> 网络 -> SSH 客户端。

by default this contains path to TortoisePlink.exe, instead of that give path to plink.exe

默认情况下,它包含 TortoisePlink.exe 的路径,而不是给出 plink.exe 的路径

Alternatively you can use ssh(.exe) in msys(git) distribution but then you cannot use private key in .ppk format/Peagent combination. You either need to export your key to OpenSSH format via PuttyGen or create a keypair using ssh-keygen instead.

或者,您可以在 msys(git) 发行版中使用 ssh(.exe),但是您不能在 .ppk 格式/Peagent 组合中使用私钥。您要么需要通过 PuttyGen 将您的密钥导出为 OpenSSH 格式,要么使用 ssh-keygen 创建一个密钥对。

回答by adam

To automate authenticating either use:

要自动进行身份验证,请使用:

  1. SSH keys as others have already pointed out, or
  2. the built-in credential helper.
  1. 其他人已经指出的 SSH 密钥,或者
  2. 内置凭证助手。

Obviously, do not store your password in a text file unless the repo is not important.

显然,除非 repo 不重要,否则不要将密码存储在文本文件中。

TortoiseGit >1.8.1 installs the helper git-credential-winstorewhich provides the local API to access and store your login info in the existing, local Windows Credential Store.

TortoiseGit >1.8.1 安装助手git-credential-winstore,它提供本地 API 来访问和存储您的登录信息在现有的本地Windows Credential Store 中

You can see the stored credentials by going to Control Panel → User Accounts → Credential Manager and choosing "Windows Credentials". The entries starting "git:" are from git-credential-winstore.

您可以通过转到控制面板 → 用户帐户 → 凭证管理器并选择“Windows 凭证”来查看存储的凭证。以“git:”开头的条目来自 git-credential-winstore。

You can set up wincred per repository by:

您可以通过以下方式为每个存储库设置 wincred:

(GUI)

(图形用户界面)

  1. Navigate to the repository in File Explorer.
  2. Context-click → TortoiseGit → Settings → Git → Credential
  3. Credential helper: wincred - this repository only
  4. The next time you authenticate with the repo, the credentials will be stored.
  1. 在文件资源管理器中导航到存储库。
  2. 上下文单击 → TortoiseGit → 设置 → Git → 凭证
  3. 凭证助手:wincred - 仅此存储库
  4. 下次您使用 repo 进行身份验证时,凭据将被存储。

(CLI, POSH)

(CLI, POSH)

  1. cmdkey /add:git:https://[email protected] /user:USERNAME /pass:PASSWORD
  2. ?

    @"
    [credential]
            helper = wincred
    "@ | Out-File -FilePath $repoRoot\.git\config -Append
    
  1. cmdkey /add:git:https://[email protected] /user:USERNAME /pass:PASSWORD
  2. ?

    @"
    [credential]
            helper = wincred
    "@ | Out-File -FilePath $repoRoot\.git\config -Append
    

You can list all credentials stored for repos with cmdkey /list:git:*
Once stored, passwords are not displayed by cmdkey (http://ss64.com/nt/cmdkey.html)

您可以使用cmdkey /list:git:*
存储后,cmdkey 不显示密码 ( http://ss64.com/nt/cmdkey.html)列出为 repos 存储的所有凭据

To list all credentials with passwords you need to use the Windows API. For powershell, there's CredMan:

要列出带密码的所有凭据,您需要使用Windows API。对于 powershell,有CredMan

. .\CredMan.ps1
.\CredMan.ps1 -ShoCred

回答by silver

I had the same issue. My environment is windows 10 with TortoiseGit 2.3.0.0 and git version 2.11.0.windows.1

我遇到过同样的问题。我的环境是带有 TortoiseGit 2.3.0.0 和 git 版本 2.11.0.windows.1 的 windows 10

The following solved my problem:

以下解决了我的问题:

  • Right click -> TortoiseGit -> Settings -> Network
  • Update SSH client to C:\Program Files\Git\usr\bin\ssh.exe
  • 右键单击 -> TortoiseGit -> 设置 -> 网络
  • 更新 SSH 客户端到 C:\Program Files\Git\usr\bin\ssh.exe

enter image description here

在此处输入图片说明

回答by Razze

What I did to fix this (windows):

我做了什么来解决这个问题(windows):

  1. Open PuttyGen import my ssh key and convert it into a putty key, save both public and private parts in the .ssh folder (%userprofile%.ssh)
  2. Open Putty and go to Connection->SSH->Auth then set your private key file there.
  3. Go back to Session, select Default Settings and hit Save.
  4. Now try to clone again and you will be asked for the passphrase on your ssh key, enter it and it should work.
  1. 打开 PuttyGen 导入我的 ssh 密钥并将其转换为 Putty 密钥,将公共和私有部分保存在 .ssh 文件夹中 (%userprofile%.ssh)
  2. 打开 Putty 并转到 Connection->SSH->Auth 然后在那里设置您的私钥文件。
  3. 返回会话,选择默认设置并点击保存。
  4. 现在尝试再次克隆,系统会要求您输入 ssh 密钥上的密码,输入它应该可以工作。

回答by Dov Grobgeld

The URL and the window title TortoisePlink both indicate that tortoise are trying to use ssh as the transport protocol. git support more than one transport protocol, including file system access, and ssh access. In your question, you are describing that you want to access your remote repo by file system access. In that case your remote url should look something like file://server/path/to/repo. Please check your remote repo URL again.

URL 和窗口标题 TortoisePlink 都表明 tortoise 正在尝试使用 ssh 作为传输协议。git 支持不止一种传输协议,包括文件系统访问和 ssh 访问。在您的问题中,您描述的是要通过文件系统访问来访问远程存储库。在这种情况下,您的远程 url 应该类似于file://server/path/to/repo. 请再次检查您的远程仓库 URL。

回答by DerVO

Pramodtech's answerstopped working for me with the current version of the official Windows Git client. It stores the ssh executable in Git\usr\bininstead of Git\binnow (since version 2.5 released in Aug 2015).

对于当前版本的官方 Windows Git 客户端,Pramodtech 的回答对我不起作用。它存储 ssh 可执行文件Git\usr\bin而不是Git\bin现在(自 2015 年 8 月发布的 2.5 版以来)。

So go to TortoiseGit > Settings > Networkand change the SSH client path to:

因此TortoiseGit > Settings > Network,将 SSH 客户端路径更改为:

C:\Program Files\Git\usr\bin\ssh.exe(or whatever the path to your Git installation is)

C:\Program Files\Git\usr\bin\ssh.exe(或者无论您的 Git 安装路径是什么)

enter image description here

在此处输入图片说明