1

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 [email protected]: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).
[email protected]: 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.

6
  • 1
    I'm interesting to know, I have the same problem plzzz Commented Jun 22, 2021 at 11:18
  • 1
    Are you using GitBash or Cygwin? Does the directory /home/user/.ssh actually exist?
    – Matt
    Commented Jun 22, 2021 at 11:58
  • I am using windows and yes I use GitBash
    – lazy_coder
    Commented Jun 22, 2021 at 12:02
  • 1
    Are you in a corporate environment where your %userprofile% path is set to a network drive? By default in Windows, the SSH keys created by will be stored in C:\users\[your user]\.ssh. This should be what maps to the '/home/[your user]/.ssh' path in the output above. The message indicates that the .ssh directory could not be found and could not be created - you could try to manually create that directory if your Git Bash can't create it. In my experience it's to be created in the %userprofile% directory. HTH! :)
    – CodeHxr
    Commented Jun 22, 2021 at 12:33
  • yes .ssh directory does exist and /home/[user]/.ssh points on c:/users/[user]/.ssh when use commands like ssh-keygen and ssh-keyscan bitbucket.org both commands work
    – lazy_coder
    Commented Jun 22, 2021 at 12:57

2 Answers 2

1

The only solution that I found is to use git clone https and in composer.lock file I modified all lines with "url": "[email protected]:namespace/package.git" to "url": "https://myusername:[email protected]/namespace/package.git"

3
  • 3
    I strongly advise against putting your username and password in the composer.lock file! This file should be checked-in and committed (see here). You definitely don't want your credentials in a Git repository.
    – Matt
    Commented Jun 22, 2021 at 13:12
  • yeah, I agree with you Matt, I had no choice, I reverted the changes in composer.loc after executing the command composer install
    – lazy_coder
    Commented Jun 23, 2021 at 11:45
  • 1
    Worked for me thank's a million bro you saved meee! Commented Jun 23, 2021 at 13:29
0

Cloning via HTTPS worked for me by creating an app password.

enter image description here

Related link:

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

So from

$ git clone https://[email protected]/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/'

To:

$ git clone https://[email protected]/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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.