在 Windows XP 上使用 git 和 tortoisegit 进行身份验证失败

发布于 2024-10-22 07:08:37 字数 497 浏览 1 评论 0原文

我的身份验证总是失败。我已经创建了 SSH 密钥,并且公钥已由本地 git 管理员导入,但仍然提示我输入密码:

git.exe clone  --progress -v  "git@repo:project.git" "C:\web\project"  
Cloning into C:\web\project...  
git@repo's password:  
fatal: The remote end hung up unexpectedly
  • 我的 SSH 密钥没有密码,位于“C:\Documents and Settings\username\”下.ssh”,我还将它们复制到“C:\Documents and Settings\username\ssh”(不带前面的点)只是为了更好地衡量。
  • 在 Windows 环境变量屏幕中,HOME 系统变量已设置为我的用户的正确目录。

My authentication keeps failing. I've created my SSH keys and the public key has been imported by the local git admin, but I still get prompted for a password:

git.exe clone  --progress -v  "git@repo:project.git" "C:\web\project"  
Cloning into C:\web\project...  
git@repo's password:  
fatal: The remote end hung up unexpectedly
  • My SSH keys are passphraseless and live under "C:\Documents and Settings\username\.ssh" and I also copied them to "C:\Documents and Settings\username\ssh" (without the preceding dot) just for good measure.
  • In the Windows environment variables screen, the HOME system var is set to the correct directory for my user.

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

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

发布评论

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

评论(1

独守阴晴ぅ圆缺 2024-10-29 07:08:37

ssh -vvv git@repo 返回什么?

只要此 ssh 请求不起作用,git@repo 服务器就无法进行任何 git 操作。
如果 ssh 报告它确实尝试提供公钥,那么您必须仔细检查它是否已正确添加到存储库服务器上的 ~git/.ssh/authorized_keys 文件中。

以下是有效的 ssh 会话示例摘录:

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /p/.ssh/mypubkey
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp f8:d9:7...:cf

debug3: sign_and_send_pubkey
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.

两条注释:

  • 我的 %HOME% 引用不是 %HOMEDIR% 而是自定义驱动器 (p:\),这是工作中的本地约定,可能不适用于您。
  • 我的公钥/私钥的名称不遵循默认标准 (id_rsa.pub/id_rsa)

我已在以下位置添加了一个 config 文件%HOME%\.ssh 目录,以便显式命名公钥文件:

host gitrepo
     user git
     hostname repo
     identityfile ~/.ssh/mypubkey

这样,我可以简单地键入:ssh gitrepo,然后 ssh 就会知道哪个用户,要使用的公钥的主机名和确切完整路径。

What does ssh -vvv git@repo returns?

As long as this ssh request doesn't work, no git operation will work with the git@repo server.
And if the ssh reports it is does try to offer the publickey, then you must double-check it has been correctly added to the ~git/.ssh/authorized_keys file on the repo server.

Here is an extract of example of a ssh session which works:

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /p/.ssh/mypubkey
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp f8:d9:7...:cf

debug3: sign_and_send_pubkey
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.

Two comments:

  • My %HOME% reference not %HOMEDIR% but a custom drive (p:\), this is a local convention at work and might not apply to you.
  • the names of my public/private keys don't follow the default standard (id_rsa.pub/id_rsa)

I have added a config file in the %HOME%\.ssh directory in order to name explicitly the public key file:

host gitrepo
     user git
     hostname repo
     identityfile ~/.ssh/mypubkey

That way, I can simply type: ssh gitrepo, and ssh will know which user, hostname and exact full path of the public key to use.

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