windows - 由于缺少公钥,无法从 bitbucket 克隆

标签 windows git bitbucket

我正在使用 bitbucket,但在我的笔记本电脑上我无法使用 git 克隆存储库。我收到一个错误:

Permission denied(publickey).

我该如何解决这个问题?我不记得设置过公钥,但如果我设置过,显然它是行不通的。 (我正在使用 Windows。)

最佳答案

这只是意味着 Git 在 %HOME%/.ssh 中找不到公钥/私钥。
这反过来意味着 shhd(服务器上的 ssh 守护进程)在服务器 ~git/.ssh/authorized_keys 中找不到匹配的公钥。

例如,您可以确保使用 https 网址(这是 OP 打算使用的网址):

cd c:\path\to\my\repo
git remote set-url origin https://bitbucket.org/<owner>/<repo>

关于 known_hosts,一个简单的 ssh -T git@bitbucket.org 将解决这个问题:

$ ssh -T git@bitbucket.org
The authenticity of host 'bitbucket.org (131.103.20.168)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)?

添加"is",bitbucket.org 将添加到 ~/.ssh/known_hosts
然而,在没有注册公钥的情况下,结果仍然是一样的。

Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,131.103.20.168' (RSA) to the list of known hosts.
Permission denied (publickey).

Windows 版 Git 上的 bash 并不奇怪:

  • msysgit/Git for windows 1.9.5 中的 git bash是旧的:

    GNU bash, version 3.1.20(4)-release (i686-pc-msys)
    Copyright (C) 2005 Free Software Foundation, Inc
    

但是有了 phasing out of msysgit (2015 年第四季度)和新的 Git For Windows (2015 年第 2 季度),您现在有 Git for Windows 2.4.4 .
它有一个更新的 bash,基于 64bits msys2 project ,基于现代 Cygwin(POSIX 兼容层)和 MinGW-w64 的 MSYS 独立重写,旨在与 native Windows 软件更好地互操作。 msys2 附带 its own installer too .

  • git bash 现在是(带有 new Git For Windows ):

    GNU bash, version 4.3.33(3)-release (x86_64-pc-msys)
    Copyright (C) 2013 Free Software Foundation, Inc.
    

关于windows - 由于缺少公钥,无法从 bitbucket 克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31092344/

相关文章:

git,我如何在 pull 出一个分支后回到原来的主人

windows - 可以在 Windows 上运行 git-annex 吗?

git - 如何避免 GitHub/BitBucket 上的 merge 提交 hell

git - 将 Bitbucket pull 请求作为补丁应用

javascript - Windows Defender 减慢 Electron 启动速度

Windows Server 2008 上的 PHP APC (PHP 5.4.3 - x64)

windows - Visualstudio 联编文件 (NMAKE)

git - 像 gitignore 但不是 git ignore

git - 获取错误 "Updates were rejected because the tip of your current branch is behind"

windows - MSYS 错误 "rem: command not found"