Error message that I am getting
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
G’day Poonam!
If you are getting this error message, it usually means that you may have your SSH keys installed locally but not within the context of the Bitbucket Cloud application which you are trying to access.
The specific error message which you have mentioned is covered within the following documentation but usually means your private key cannot authenticate with your public key stored in Bitbucket Cloud:
Troubleshoot SSH Issues
There are a few places where SSH keys will reside:
cat ~/.ssh/id_rsa.pub | pbcopyNOTE: If you intend to use existing keys, you cannot have a passphrase configured on your SSH key - this will prevent you from connecting on pipelines. To remove the passphrase, it’s easiest to generate a new SSH key pair and follow steps above.
cat ~/.ssh/id_rsa | pbcopy
ssh -T git@bitbucket.orgNOTE: As this is a public post, please make sure you don’t include your real account name in your reply.
Please feel free to reach out if you have any further questions.
Cheers!
Ben
Using runner version 1.301
I generated an SSH keypair for repository X (under pipeline -> SSH keys)
I added the public key of that pair to repository Y (under access keys).. so as I understand, this will allow me to pull from the repository using the private key
Repository X is a ruby project which uses rubygems to refer to repository Y
gem 'y', git: 'git@bitbucket.org:us/y.git'
Then during the bundle install I get the following error (permission denied)
#13 [build 4/5] RUN bundle install
#13 0.446 Fetching git@bitbucket.org:us/y.git
#13 0.809 Warning: Permanently added the RSA host key for IP address '104.192.141.1' to the list of known hosts.
#13 0.809 Permission denied (publickey).
#13 0.809 fatal: Could not read from remote repository.
#13 0.809
#13 0.809 Please make sure you have the correct access rights
#13 0.809 and the repository exists.
#13 0.809
#13 0.809 Retrying `git clone 'git@bitbucket.org:us/y.git' "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72" --bare --no-hardlinks --quiet` due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git@bitbucket.org:us/y.git' "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72" --bare --no-hardlinks --quiet` in directory /usr/app has failed.Permission denied (publickey).
#13 1.174 fatal: Could not read from remote repository.
#13 1.174
#13 1.174 Please make sure you have the correct access rights
#13 1.174 and the repository exists.
#13 1.174
#13 1.174 Retrying `git clone 'git@bitbucket.org:us/y.git' "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72" --bare --no-hardlinks --quiet` due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git@bitbucket.org:us/y.git' "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72" --bare --no-hardlinks --quiet` in directory /usr/app has failed.Permission denied (publickey).
#13 1.536 fatal: Could not read from remote repository.
#13 1.536
#13 1.536 Please make sure you have the correct access rights
#13 1.536 and the repository exists.
#13 1.536
#13 1.536 Retrying `git clone 'git@bitbucket.org:us/y.git' "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72" --bare --no-hardlinks --quiet` due to error (4/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git@bitbucket.org:us/y.git' "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72" --bare --no-hardlinks --quiet` in directory /usr/app has failed.Permission denied (publickey).
#13 1.903 fatal: Could not read from remote repository.
#13 1.903
#13 1.903 Please make sure you have the correct access rights
#13 1.903 and the repository exists.
#13 1.904
#13 1.909 Git error: command `git clone
#13 1.909 'git@bitbucket.org:us/y.git'
#13 1.909 "/usr/local/bundle/cache/bundler/git/y-baf6ba6507685bbba040117b4db444b8f4a2bf72"
#13 1.909 --bare --no-hardlinks --quiet` in directory /usr/app has failed.
#13 ERROR: executor failed running [/bin/sh -c bundle install]: exit code: 11
I can verify that the private key is injected into the runner onder /tmp as you mentioned. How can I have the pipeline use this private key by default when trying to pull from the private repo?
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Poonam,
The error that you are receiving appears to indicate that the public key between your Pipelines SSH and Account-Level SSH does not match. This is because Pipelines will authenticate any keys contained within its settings against your account-level SSH.
Can you please access Personal Settings > SSH Keys and ensure that the key here is copied into and is the same as in Repository Settings > Pipelines SSH?
Cheers
- Ben (Bitbucket Cloud Support)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.