A quite probably relevant piece of information is that I have a custom ssh config set up for bitbucket. In my '.ssh/config' file I have the following:
[ivanna@comp]$ cat ~/.ssh/config
Host bitbucket
Hostname bitbucket.org
IdentityFile /home/ivanna/.ssh/id_rsa_bitbucket
IdentitiesOnly yes
The permissions on this file are definitely correct as far as ssh is concerned (I actively use other entries in the config file). Now when I added the remote origin in git I used bitbucket instead of bitbucket.org:
git remote add origin bitbucket:ivanna/my-repo.git
but when I try to push I get the following error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So it seems like I didn't add my public key or something, right? But I definitely did. And when you search for more information you find this page about the error (https://confluence.atlassian.com/pages/viewpage.action?pageId=302811860). And when I do what they say to do to check the key:
[ivanna@comp]$ ssh -T hg@bitbucket
logged in as ivanna.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
It can login fine, it seems. So... why doesn't pushing work? The above link mentions that it could be a permissions issue on the project itself but I set the permissions as people suggested and it did nothing. Anybody know what's going on?
Make sure the authorized_keys file and the private key itself have the correct permissions and ownership. Check that key-based authentication is allowed by the server. Make sure the private key is readable by the SSH client. If you're using PuTTY, make sure your SSH keys are properly configured for the session.
From Bitbucket, go to the repository and click Repository settings. Click Access keys from the left menu. Press Add key. From the Add SSH key dialog, enter a Label and paste the public key from the clipboard.
ssh -T hg@bitbucket
You use hg@bitbucket
when logging in via SSH, but in the remote URL you add to Git, you don’t specify a username. Since the configuration also does not include one, Git won’t know what username to log in with.
Change the URL to this:
git remote add origin git@bitbucket:ivanna/my-repo.git
Alternatively, you can add the user to the SSH config:
Host bitbucket
Hostname bitbucket.org
User git
IdentityFile /home/ivanna/.ssh/id_rsa_bitbucket
IdentitiesOnly yes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With