I'm using bitbucket.org
to my manage my repositories both at work and personally.
On my new MacBook Pro, I generated a new SSH key and then added that to my work account on bitbucket.org and have had no issues with committing my work. This key is saved on my machine at ~/.ssh/id_rsa
.
Now, I am trying to add my personal account on the machine, and having all types of issues with committing my work.
I generated a ssh
key using the following command:
ssh-keygen
I saved this key at ~/.ssh/id_personal_rsa
and then copy the key into my personal bitbucket.org account.
I then created a config
file at ~/.ssh/config
that has the follow entries:
Host *
IdentityFile ~/.ssh/id_rsa
Host bitbucket.org-personal
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_personal_rsa
IdentitiesOnly yes
(The personal
string is just replaced with my actual account name.)
Now, for the issue, when I try and commit work, I am getting this error:
Git: [email protected]: Permission denied (publickey).
This is the config
file for my .ssh connection in my project:
[remote "origin"]
url = [email protected]:personal/my-personal-project.git
fetch = refs/heads/*:refs/remotes/origin/*
Any thoughts on what I may have configured incorrectly?
UPDATE: I've updated my config for my personal account to reflect some of the answers from this post and from this link:
- Remove the SSH key from the repo.
(Click onrepo name > Settings > Access Keys
)- Add SSH key to Account settings SSH keys.
(Click on youravatar > Bitbucket Settings > SSH Keys
)
As mentioned in "Can't git push to Bitbucket: Unauthorized - fatal: Could not read from remote repository"
adding the keys under the repo only gives you a read-only access.
For read and write access, you need to add your keys under your account.