我的身份验证一直失败。我已经创建了我的 SSH key 并且公钥已由本地 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 key 是无密码的,位于“
C:\Documents and Settings\username\.ssh
”下,我还将它们复制到“C:\Documents and Settings\username\ssh
”(没有前面的点)只是为了更好的衡量。 - 在 Windows 环境变量屏幕中,
HOME
系统变量已设置为我的用户的正确目录。
最佳答案
ssh -vvv git@repo
返回什么?
只要这个 ssh 请求不工作,git 操作就不会在 git@repo
服务器上工作。
如果 ssh 报告确实尝试提供公钥,那么您必须仔细检查它是否已正确添加到 repo 服务器上的 ~git/.ssh/authorized_keys
文件中。
这是一个有效的 ssh session 示例的摘录:
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
)
我在 %HOME%\.ssh
目录中添加了一个 config
文件,以便明确命名公钥文件:
host gitrepo
user git
hostname repo
identityfile ~/.ssh/mypubkey
这样,我只需键入:ssh gitrepo
,ssh 就会知道要使用哪个用户、主机名和公钥的确切完整路径。
关于windows - 使用 git 和 tortoisegit 在 Windows XP 上验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5318590/