I have followed a million guides regarding this and I cannot get it to work. Earlier, I successfully pushed via SSH to my private Bitbucket git repository, now suddenly it wont work.
I have recreated the keys with a new passphrase, added it to my Bitbucket settings and it wont work.
Okay, here are the steps I took:
- Deleted old key pair (project1 and project1.pub)
- Recreated it with this command
ssh-keygen -f ~/.ssh/project1 -C "project1"
- Created a
config
in~/.ssh
file for my two Bitbucket accounts, with the following contents:
Host project1
HostName bitbucket.org
IdentityFile ~/.ssh/project1
Host project2
HostName bitbucket.org
IdentityFile ~/.ssh/project2
- Grabbed the contents of
project1.pub
and created a new SSH key entry in my Bitbucket account. - Added
ssh-agent
in my~/.zshrc
plugin list like this:plugins=(git ssh-agent)
and restarted Terminal - Did
ssh-add -l
and saw onlyproject2
was loaded - Did
ssh-add ~/.ssh/project1
, entered my passphrase and success, like this:
2048 SHA256:THESHA256 /Users/myuser/.ssh/project2 (RSA)
2048 SHA256:THESHA256 /Users/myuser/.ssh/project1 (RSA)
- Restarted Terminal and did
ssh-add -l
and it listed both entries - Went to my project and did
git push
and it told me I had no access.
When I do ssh -T git@bitbucket.com
, it tells me I'm logged in with the username of project2.
logged in as project2_user.
My system is OS X 10.11.5
I could never fix multiple identities on my computer and always used HTTPS, but I need to make everything more secure with SSH, which also allows my account to have two-factor authentication. Therefore using SSH is a must now and I don't know what to do.
P.S: I did the creating steps for the identity for project2 too, but I'm fairly certain that it doesn't work either.
Guide I followed:
EDIT
project2 has no passphrase, while project1 does! Just thought maybe this is relevant.
EDIT 2
I did ssh-add -D
to remove all loaded keys, then added the key for project1, entered passphrase and pushed. It worked. But now my other identity is not working because its key is not loaded.
Why aren't my multiple identities working?