作曲家权限被拒绝(公钥)

Composer permission denied (publickey)

我在 BitBucket 上有一个私人仓库,我正在尝试使用 composer install 在本地主机上安装,这是我的 composer.json 文件:

{
"repositories": [
    {
        "type": "git",
        "url":  "git@bitbucket.org:username/repo.git"
    }
]
}

当我从命令行 运行 composer 安装时,我得到:

[RuntimeException] Failed to execute git clone --mirror "git@bitbucket.org:username/repo.git" "C:/Users/...../" Cloning into bare repository 'C:/Users/.....'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

我的密钥对有一个密码短语,但作曲家从来没有要求过它,我 运行ning windows 10 与选美客户端 运行ning 和正确的密钥选择。

还有一个包含此数据的配置文件:

Host bitbucket.org
IdentityFile ~/.ssh/openssh (yes my key name is openssh)

有趣的是,如果我复制并粘贴此命令:

git clone --mirror "git@bitbucket.org:username/repo.git"

确实有人要求我输入密码,然后它开始克隆 Repo。

有什么问题吗?有关此错误的大部分信息直接针对 git 命令,但在我的情况下它们有效,作曲家不起作用,我做错了什么?

1。确保您的 public 密钥已加载到 Bitbucket Cloud

  1. 打开浏览器并登录到 Bitbucket Cloud。
  2. 从菜单栏中选择“用户名”>“管理帐户”。系统显示账户设置页面。
  3. 点击 SSH 密钥。显示 SSH 密钥页面。它显示所有现有密钥的列表。
  4. 如果您的密钥未列出,请设置一个。

2。确保您的身份已加载到 SSH 代理中

打开 Pageant 查看加载的密钥。如果您的密钥不在列表中,请单击 Add Key

您可以测试发送的是哪个密钥

ssh -T git@bitbucket.org

我遇到了同样的问题,这个 post 的答案对我很有帮助 Why git can't remember my passphrase under Windows

我所做的只是在 CMD 中 运行 'start-ssh-agent' 并提供密码。

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

Install msysgit

Make sure to allow git to be used on the MS-DOS

command prompt Run start-ssh-agent

Enter SSH passphrases

All done! Git commands should now work in the native command prompt.

遇到了与 OP 描述的相同问题,我也尝试按照 Why git can't remember my passphrase under Windows

上的说明进行操作

但我将我的步骤限制为这些:

  1. 运行 PuTTY 的 pageant.exe,打开您的 .ppk 文件 ("Add Key"),然后 为您的密钥提供密码。
  2. 访问Windows'环境 变量对话框(右键单击 "Computer",单击 "Properties", 单击 "Advanced system settings" 或 "Advanced" 选项卡,单击 "Environment Variables")。添加以下环境变量:

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

重新启动命令行工具后(重要的是让新的环境变量生效)它起作用了。