无法使用 SSH 从 BitBucket 克隆

Can't clone from BitBucket using SSH

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

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 生成私钥和 public 密钥时,我得到了 RSA 密钥指纹 SHA256:xV8l3qRhTRnFgRrZly1+ygQP9fqoANzqbuaYAVO1j9M

我还在 bitbucket 帐户中添加了 public 密钥并添加了一行 known_hosts (bitbucket.org,104.192.141.1 ssh-rsa public key... ) , 但还是没用。

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

通过 HTTPS 克隆通过创建应用程序密码对我有用。

相关link:

https://community.atlassian.com/t5/Bitbucket-questions/set-password-when-using-google-authentication/qaq-p/967729

所以从

$ git clone https://xxx@bitbucket.org/xxx/xxx.git
Cloning into 'xxx'...
Enter Bitbucket credentials for 'https://bitbucket.org/'...
Username: xxx
Password:
fatal: Invalid credentials
remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/xxx/xxx.git/'

收件人:

$ git clone https://xxx@bitbucket.org/xxx/xxx.git
Cloning into 'xxx'...
Enter Bitbucket credentials for 'https://bitbucket.org/'...
Username: xxx
Password:
remote: Enumerating objects: 2073, done.
remote: Counting objects: 100% (2073/2073), done.
remote: Compressing objects: 100% (795/795), done.
remote: Total 2073 (delta 1153), reused 1648 (delta 899), pack-reused 0
Receiving objects: 100% (2073/2073), 23.65 MiB | 1.76 MiB/s, done.     
Resolving deltas: 100% (1153/1153), done.