为什么 git 要求我输入密码?

发布于 2024-12-27 13:24:16 字数 576 浏览 4 评论 0原文

我正在使用 Windows XP、TortoiseGit(最新版本)和 Cygwin。我已经安装了 git.exe 并在我的路径上。在 TortoiseGit 中,我可以对远程存储库执行推送,而不会提示输入密码。我认为这是因为我已经在 .git/config 文件中定义了这一点...

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://git@myrepo/myproject.git
    puttykeyfile = U:\\.ssh\\mykey.ppk

但是,在 Cygwin 中,当位于我的项目的根目录(.git 文件夹是子目录的目录)时,系统会提示我输入密码 ...

$ git push origin qa_release
git@myrepo's password:

为什么当我尝试从 Cygwin 推送而不是从 TortoiseGit 推送时会提示输入密码,如何让 Cygwin 表现得像 TortoiseGit (即不要求我输入密码)?

谢谢,-戴夫

I'm using Windows XP, TortoiseGit (latest version) and Cygwin. I have git.exe installed and on my path. In TortoiseGit, I can execute pushes against the remote repository without being prompted for a password. I assumed this was because I have defined this in my .git/config file ...

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://git@myrepo/myproject.git
    puttykeyfile = U:\\.ssh\\mykey.ppk

However, in Cygwin, when at the root directory of my project (the one where the .git folder is a child), I get prompted for a password ...

$ git push origin qa_release
git@myrepo's password:

Why am I prompted for a password when trying to push from Cygwin but not from TortoiseGit and how can I get Cygwin to behave like TortoiseGit (i.e. not ask me for a password)?

Thanks, - Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气尐潴 2025-01-03 13:24:16

puttykeyfile 是 Windows git 的东西,所以你也需要为 cygwin 设置 SSH。 Git 将使用您的常规 SSH 设置。

.ppk 文件是常规 SSH 公钥吗?如果是这样,请将以下内容添加到您的 ~/.ssh/config 文件中,以便 cygwin git 知道在哪里可以找到它。

 Host myrepo
     IdentityFile /cygdrive/u/.ssh/mykey.ppk

您可以在 cygwin 中使用 ssh myrepo 快速测试这一点。

puttykeyfile is a windows git thing, so you need to have your SSH set up for cygwin too. Git will use your regular SSH settings.

Is the .ppk file a regular SSH public key? If so, add the following to your ~/.ssh/config file, so cygwin git knows where to find it.

 Host myrepo
     IdentityFile /cygdrive/u/.ssh/mykey.ppk

You can test this quickly with a ssh myrepo in cygwin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文