Search code examples
gitsshbitbucketgit-bashgit-clone

Can't clone from BitBucket using SSH


I have no choice I must use git clone with ssh so after that when I use composer install it will downlonad some dependencies from bitbucket using git clone ssh when I try run git clone using SSH,

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

I get this output

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.

I do not know from where it get RSA key fingerprint SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A when generated private key and public key using the command line ssh-keygen and I got RSA key fingerprint SHA256:xV8l3qRhTRnFgRrZly1+ygQP9fqoANzqbuaYAVO1j9M

I also added the public key in bitbucket account and added a line known_hosts (bitbucket.org,104.192.141.1 ssh-rsa public key... ), but still no use.


Solution

  • The only solution that I found is to use git clone https and in composer.lock file I modified all lines with "url": "git@bitbucket.org:namespace/package.git" to "url": "https://myusername:mypassword@bitbucket.org/namespace/package.git"