【问题标题】:Can't clone from BitBucket using SSH无法使用 SSH 从 BitBucket 克隆
【发布时间】:2021-09-05 23:42:47
【问题描述】:

我别无选择,我必须将 git clone 与 ssh 一起使用,所以之后当我使用 composer install 时,它将使用 git clone ssh 从 bitbucket 下载一些依赖项 当我尝试使用 SSH 运行 git clone 时,

git clone git@bitbucket.org:namespace/project.git

我得到这个输出

Cloning into 'project'...
The authenticity of host 'bitbucket.org (104.192.141.1)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/user/.ssh' (No such file or directory).
Failed to add the host to the list of known hosts (/home/user/.ssh/known_hosts).
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我不知道从哪里得到 RSA 密钥指纹SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A 当使用命令行 ssh-keygen 生成私钥和公钥时,我得到了 RSA 密钥指纹SHA256:xV8l3qRhTRnFgRrZly1+ygQP9fqoANzqbuaYAVO1j9M

我还在bitbucket账户里加了公钥,加了一行known_hosts(bitbucket.org,104.192.141.1 ssh-rsa public key...),还是没用。

【问题讨论】:

  • 我很高兴知道,我也有同样的问题 plzzz
  • 您使用的是 GitBash 还是 Cygwin?目录/home/user/.ssh 真的存在吗?
  • 我使用的是 windows,是的,我使用的是 GitBash
  • 您是否处于将 %userprofile% 路径设置为网络驱动器的公司环境中?默认情况下,在 Windows 中,创建的 SSH 密钥将存储在 C:\users\[您的用户]\.ssh 中。这应该是映射到上面输出中的“/home/[your user]/.ssh”路径的内容。该消息表明 .ssh 目录无法找到且无法创建 - 如果您的 Git Bash 无法创建该目录,您可以尝试手动创建该目录。根据我的经验,它是在 %userprofile% 目录中创建的。 ! :)
  • 是的 .ssh 目录确实存在,并且 /home/[user]/.ssh 在使用 ssh-keygen 和 ssh-keyscan bitbucket 等命令时指向 c:/users/[user]/.ssh。 org 两个命令都有效

标签: git ssh bitbucket git-bash git-clone


【解决方案1】:

我找到的唯一解决方案是使用 git clone https 并在 composer.lock 文件中我修改了所有带有 "url": "git@bitbucket.org:namespace/package.git" 的行到 "url": "https ://myusername:mypassword@bitbucket.org/namespace/package.git"

【讨论】:

  • 我强烈建议不要将您的用户名和密码放在 composer.lock 文件中!该文件应该被签入并提交(参见here)。您绝对不希望您的凭据在 Git 存储库中。
  • 是的,我同意你的观点,马特,我别无选择,我在执行 composer install 命令后恢复了 composer.loc 中的更改
  • 为我工作,谢谢你救了我的一百万兄弟!
猜你喜欢
  • 1970-01-01
  • 2020-03-20
  • 2019-05-24
  • 2019-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-19
相关资源
最近更新 更多