为什么git不能记住我在Windows下的密码 [英] Why git can't remember my passphrase under Windows

查看:388
本文介绍了为什么git不能记住我在Windows下的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



但我仍然得到

  * \subnus.mvc> git push origin master 
输入密钥'/c/Users/Subnus/.ssh/id_rsa'的密码:


解决方案

我意识到这个问题是两年前出现的,但我有同样的问题,这里的几个答案没有完全回答我的问题。



第一个解决方案假设Windows是基于Windows的, msysgit和PuTTY。


  1. 按照说明安装msysgit和PuTTY。

  2. 到你的路。 (如果不这样做,则下面对任何引用的PuTTY命令必须以适当的可执行文件的完整路径为前缀。)

  3. 这样做已经这样,然后生成密钥哈希按照GitHub的指示或按照您的Git主机的指示。

  4. 同样,如果您还没有这样做,转换您的密钥用于PuTTY的页面.exe使用 puttygen.exe 。有关说明,请参阅PuTTY的文档,此帮助指南和网络空间中的其他几个地方。

  5. 运行PuTTY的 pageant.exe ,打开您的.ppk文件(添加密钥),并提供您的密钥的密码。

  6. 访问Windows环境变量对话框(右键单击计算机,单击属性,单击高级系统设置或高级选项卡,单击环境变量。添加以下环境变量:



    GIT_SSH = C:\full\path\to\plink.exe



    将完整安装路径替换为C:\full \path\to,以便找到plink.exe。最好将其添加到用户变量部分。此外,确保您使用plink.exe的路径与用于Pageant(pageant.exe)的路径匹配。在某些情况下,您可能有几个安装的PuTTY,因为它可能与其他应用程序一起安装。


  7. 打开命令提示符。

  8. 使用plink.exe从另一个安装程序和pageant.exe可能会导致麻烦。
  9. 如果您尝试连接到Gitub.com上托管的git存储库,请运行以下命令:



    plink.exe git @ github.com



    如果您尝试连接的git存储库托管在其他地方,请将 git@github.com <适当的用户名和URL。 (假设Github)你应该被告知,服务器的主机密钥没有缓存,并询问你是否信任它。使用 y 回答。这将把服务器的主机密钥添加到PuTTY的已知主机列表中。没有这一步,git命令将无法正常工作。在进入后,Github通知你Github不提供shell访问。这很好...我们不需要它。 (如果你连接到其他主机,并且它给你shell访问,最好是终止链接,而不做任何其他事情。)


  10. 全部完成! Git命令现在应该从命令行工作。您可能希望pageant.exe 在引导时自动加载.ppk文件
  11. msysgit和TortoiseGit。



    TortoiseGit附带了PuTTY可执行文件,以及特殊修改的plink(称为TortoisePlink.exe) b
    $ b


    1. 按照说明安装msysgit和TortoiseGit。

    2. 如果您还没有这样做,

    3. 同样,如果您还没有这样做,请使用TortoiseGit的pageant.exe将您的密钥转换为使用TortoiseGit的 puttygen.exe

    4. 运行TortoiseGit的 pageant.exe ,打开您的

    5. 访问Windows环境变量对话框(右键单击计算机,单击添加密钥属性,单击高级系统设置或高级选项卡,单击环境变量)。添加以下环境变量:



      GIT_SSH = C:\full \path\to\TortoisePlink.exe



      使用TortoiseGit的完整安装路径替换C:\full\path\to,其中找到TortoisePlink.exe。最好将其添加到用户变量部分。此外,确保您使用TortoisePlink.exe的路径与用于Pageant(pageant.exe)的路径匹配。在某些情况下,您可能有几个安装的PuTTY,因为它可能与其他应用程序一起安装。使用TortoiseGit安装中的TortoisePlink.exe和另一个安装不同应用程序(或独立PuTTY安装)的pageant.exe可能会导致麻烦。


    6. 全部完成! Git命令现在应该从命令行工作。第一次尝试连接到您的git存储库时,您可能会被告知服务器的主机密钥未缓存,并询问您是否信任该服务器。点击是。 (这是TortoisePlink.exe在操作中。)



      您可能希望有pageant.exe 在启动时自动加载.ppk文件,具体取决于您需要的频率。


    第三个解决方案假设Window,msysgit和本机命令提示符。


    1. 安装msysgit

    2. 确保允许在MS-DOS命令提示符下使用git

    3. 运行 start-ssh-agent

    4. 输入SSH密码

    5. Git命令现在应该在本机命令提示符下工作。


    I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github

    but i still get

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

    解决方案

    I realize that this question is coming up on two years old, but I had the same issue and several answers here did not completely answer the question for me. Here is two step-by-step solutions, depending on whether you use TortoiseGit in addition to msysgit or not.

    First solution Assumes Windows, msysgit, and PuTTY.

    1. Install msysgit and PuTTY as instructed.
    2. (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.)
    3. If you have not done so already, then generate a key hash as instructed at GitHub or as instructed by your Git host.
    4. 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.
    5. Run PuTTY's pageant.exe, open your .ppk file ("Add Key"), and provide your passphrase for your key.
    6. 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.

    7. Open a command prompt.

    8. 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.)

    9. 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.

    Second solution Assumes Windows, msysgit, and TortoiseGit.

    TortoiseGit comes with PuTTY executables, and a specially modified version of plink (called TortoisePlink.exe) that will make things easier.

    1. Install msysgit and TortoiseGit as instructed.
    2. If you have not done so already, then generate a key hash as instructed at GitHub or as instructed by your Git host.
    3. 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 several other places in cyberspace.
    4. Run TortoiseGit's pageant.exe, open your .ppk file ("Add Key"), and provide your passphrase for your key.
    5. 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.

    6. 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.

    Third solution Assumes Window, msysgit, and native command prompt.

    1. Install msysgit
    2. Make sure to allow git to be used on the MS-DOS command prompt
    3. Run start-ssh-agent
    4. Enter SSH passphrases
    5. All done! Git commands should now work in the native command prompt.

    这篇关于为什么git不能记住我在Windows下的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆