我刚刚开始使用git,我不能让它记住我的密码,我使用cmd.exe提升,我的git主机是github,我已经创建了一个ssh密钥,就像github上的指南

但我还是得到了

*\subnus.mvc>git push origin master
Enter passphrase for key '/c/Users/Subnus/.ssh/id_rsa':

当前回答

我意识到这个问题在两年前就出现了,但我也有同样的问题,这里的几个答案并没有完全回答我的问题。以下是三个分步解决方案,具体取决于您是否使用TortoiseGit和msysgit。

第一种方案以Windows、msysgit、PuTTY为例。

Install msysgit and PuTTY as instructed. (Optional) Add PuTTY to your path. (If you do not do this, then any references to PuTTY commands below must be prefixed with the full path to the appropriate executable.) If you have not done so already, then generate a key hash as instructed at GitHub or as instructed by your Git host. Again, if you have not already done so, convert your key for use with PuTTY's pageant.exe using puttygen.exe. Instructions are in PuTTY's documentation, in this helpful guide, and several other places in cyberspace. Run PuTTY's pageant.exe, open your .ppk file ("Add Key"), and provide your passphrase for your key. Access Windows' environment variables dialog (Right-click on "Computer", Click on "Properties", Click on "Advanced system settings" or the "Advanced" tab, click on "Environment Variables"). Add the following environment variable: GIT_SSH=C:\full\path\to\plink.exe Replace "C:\full\path\to" with the full installation path to PuTTY, where plink.exe is found. It is probably best to add it to the "User variables" section. Also, make sure that the path you use to plink.exe matches the path you use for Pageant (pageant.exe). In some cases, you may have several installations of PuTTY because it might be installed along with other applications. Using plink.exe from one installation and pageant.exe from another will likely cause you trouble. Open a command prompt. If you are trying to connect to a git repository hosted at Github.com then run the following command: plink.exe git@github.com If the git repository you are trying to connect to is hosted somewhere else, then replace git@github.com with an appropriate user name and URL. (Assuming Github) You should be informed that the server's host key is not cached, and asked if you trust it. Answer with a y. This will add the server's host key to PuTTY's list of known hosts. Without this step, git commands will not work properly. After hitting enter, Github informs you that Github does not provide shell access. That's fine...we don't need it. (If you are connecting to some other host, and it gives you shell access, it is probably best to terminate the link without doing anything else.) All done! Git commands should now work from the command line. You may want to have pageant.exe load your .ppk file automatically at boot time, depending on how often you'll be needing it.

第二种方案假设Windows、msysgit和TortoiseGit。

TortoiseGit附带了PuTTY可执行文件和一个经过特别修改的plink版本(称为TortoisePlink.exe),这将使事情变得更简单。

Install msysgit and TortoiseGit as instructed. If you have not done so already, then generate a key hash as instructed at GitHub or as instructed by your Git host. Again, if you have not already done so, convert your key for use with TortoiseGit's pageant.exe using TortoiseGit's puttygen.exe. Instructions are in PuTTY's documentation, in the helpful guide linked to in the first solution, and in several other places in cyberspace. Run TortoiseGit's pageant.exe, open your .ppk file ("Add Key") and provide your passphrase for your key. Access Windows' environment variables dialog (Right-click on "Computer", Click on "Properties", Click on "Advanced system settings" or the "Advanced" tab, click on "Environment Variables"). Add the following environment variable: GIT_SSH=C:\full\path\to\TortoisePlink.exe Replace "C:\full\path\to" with the full installation path to TortoiseGit, where TortoisePlink.exe is found. It is probably best to add it to the "User variables" section. Also, make sure that the path you use to TortoisePlink.exe matches the path you use for Pageant (pageant.exe). In some cases, you may have several installations of PuTTY because it might be installed along with other applications. Using TortoisePlink.exe from the TortoiseGit installation and pageant.exe from another installation of a different application (or from a standalone PuTTY installation) will likely cause you trouble. All done! Git commands should now work from the command line. The first time you try to connect to your git repository you will probably be informed that the server's host key is not cached, and asks if you trust the server. Click on "Yes". (This is TortoisePlink.exe in action.) You may want to have pageant.exe load your .ppk file automatically at boot time, depending on how often you'll be needing it.

第三种方案假设Windows、msysgit和本机命令提示符。

安装msysgit 确保允许在MS-DOS命令提示符上使用git 运行start-ssh-agent 输入SSH密码 全部完成!Git命令现在应该在本机命令提示符中工作。

其他回答

在问题发布5年8个月零6天后再做一个解决方案也不是什么坏主意。

注意:假设您使用的是windows计算机。

下载git-credential-winstore。 运行它!如果PATH环境变量中有GIT,它应该可以工作。如果没有,运行git-credential-winstore -i C:\Path\To\Git.exe。

下次尝试提交到存储库时,系统将提示您输入凭据。应该是这样。在您更改密码之前,您将不再被要求提供您的凭证。


只是为了让你知道…您的凭据存储在Windows凭据存储中

你把我的证件放在哪里? 这个应用程序只是使用现有的Windows凭据商店来保存您的凭据。您可以通过进入控制面板>用户帐户>凭证管理器并选择“Windows凭证”来查看存储的凭证。以“git:”开头的条目来自git-credential-winstore。

我意识到这个问题已经拖延了好几年,但我无意中发现了这个问题,试图找到一个解决方案,我发现了一些适合所有专业水平的东西,所以我想我应该分享一下。

GitHub提供了一个非常有用的安装程序,使一切都很好很简单:https://help.github.com/articles/caching-your-github-password-in-git/

我意识到这个问题在两年前就出现了,但我也有同样的问题,这里的几个答案并没有完全回答我的问题。以下是三个分步解决方案,具体取决于您是否使用TortoiseGit和msysgit。

第一种方案以Windows、msysgit、PuTTY为例。

Install msysgit and PuTTY as instructed. (Optional) Add PuTTY to your path. (If you do not do this, then any references to PuTTY commands below must be prefixed with the full path to the appropriate executable.) If you have not done so already, then generate a key hash as instructed at GitHub or as instructed by your Git host. Again, if you have not already done so, convert your key for use with PuTTY's pageant.exe using puttygen.exe. Instructions are in PuTTY's documentation, in this helpful guide, and several other places in cyberspace. Run PuTTY's pageant.exe, open your .ppk file ("Add Key"), and provide your passphrase for your key. Access Windows' environment variables dialog (Right-click on "Computer", Click on "Properties", Click on "Advanced system settings" or the "Advanced" tab, click on "Environment Variables"). Add the following environment variable: GIT_SSH=C:\full\path\to\plink.exe Replace "C:\full\path\to" with the full installation path to PuTTY, where plink.exe is found. It is probably best to add it to the "User variables" section. Also, make sure that the path you use to plink.exe matches the path you use for Pageant (pageant.exe). In some cases, you may have several installations of PuTTY because it might be installed along with other applications. Using plink.exe from one installation and pageant.exe from another will likely cause you trouble. Open a command prompt. If you are trying to connect to a git repository hosted at Github.com then run the following command: plink.exe git@github.com If the git repository you are trying to connect to is hosted somewhere else, then replace git@github.com with an appropriate user name and URL. (Assuming Github) You should be informed that the server's host key is not cached, and asked if you trust it. Answer with a y. This will add the server's host key to PuTTY's list of known hosts. Without this step, git commands will not work properly. After hitting enter, Github informs you that Github does not provide shell access. That's fine...we don't need it. (If you are connecting to some other host, and it gives you shell access, it is probably best to terminate the link without doing anything else.) All done! Git commands should now work from the command line. You may want to have pageant.exe load your .ppk file automatically at boot time, depending on how often you'll be needing it.

第二种方案假设Windows、msysgit和TortoiseGit。

TortoiseGit附带了PuTTY可执行文件和一个经过特别修改的plink版本(称为TortoisePlink.exe),这将使事情变得更简单。

Install msysgit and TortoiseGit as instructed. If you have not done so already, then generate a key hash as instructed at GitHub or as instructed by your Git host. Again, if you have not already done so, convert your key for use with TortoiseGit's pageant.exe using TortoiseGit's puttygen.exe. Instructions are in PuTTY's documentation, in the helpful guide linked to in the first solution, and in several other places in cyberspace. Run TortoiseGit's pageant.exe, open your .ppk file ("Add Key") and provide your passphrase for your key. Access Windows' environment variables dialog (Right-click on "Computer", Click on "Properties", Click on "Advanced system settings" or the "Advanced" tab, click on "Environment Variables"). Add the following environment variable: GIT_SSH=C:\full\path\to\TortoisePlink.exe Replace "C:\full\path\to" with the full installation path to TortoiseGit, where TortoisePlink.exe is found. It is probably best to add it to the "User variables" section. Also, make sure that the path you use to TortoisePlink.exe matches the path you use for Pageant (pageant.exe). In some cases, you may have several installations of PuTTY because it might be installed along with other applications. Using TortoisePlink.exe from the TortoiseGit installation and pageant.exe from another installation of a different application (or from a standalone PuTTY installation) will likely cause you trouble. All done! Git commands should now work from the command line. The first time you try to connect to your git repository you will probably be informed that the server's host key is not cached, and asks if you trust the server. Click on "Yes". (This is TortoisePlink.exe in action.) You may want to have pageant.exe load your .ppk file automatically at boot time, depending on how often you'll be needing it.

第三种方案假设Windows、msysgit和本机命令提示符。

安装msysgit 确保允许在MS-DOS命令提示符上使用git 运行start-ssh-agent 输入SSH密码 全部完成!Git命令现在应该在本机命令提示符中工作。

可以尝试添加-k arg当你这样做;

ssh-add -k ~/.ssh/id_rsa

确保你的~/。Ssh /config不包含

UseKeychain是的

防止ssh-add持久化到ssh-agent。