1

I already have a github account and using it without a problem using gitbash -clone/pull/push. Now I currently created another github account to work with a friend and realized I couldn't push due to account conflict or whatever it is called. So I created a new ssh key and went through a few threads but still didn't get it working but I am able to authenticate between two different git accounts but now I couldn't push or clone due to access rights.

I don't remember the exact all steps I did because I was going through different threads and trying different things. By the way I'm using windows.

1st

I went to the /.ssh and changed my previous id_rsa and id_rsa.pub into id_rsa_acc1 and id_rsa_acc2

2nd

I created another key using ssh-keygen -t rsa -C "email@email.com" my previous ssh uses the same email too

3rd

I went to the /.ssh and changed my new id_rsa and id_rsa.pub into id_rsa_acc2 and id_rsa_acc2

4th

in .ssh folder I created a file called config and added

# acc1 GitHub
Host acc1 .github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_acc1

# acc2 GitHub
Host acc2.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_acc2

5th

I login into github.com with my acc2 and added the ssh key in /.ssh/id_rsa_acc2.pub into github settings>SSH keys

6th

eval `ssh-agent -s`
ssh-add

7th

ssh-add ~/.ssh/id_rsa_acc1
ssh-add ~/.ssh/id_rsa_acc2

8th

ssh -T git@acc1.github.com
Hi acc1! You've successfully authenticated, but GitHub does not provide shell access.

ssh -T git@acc2.github.com
Hi acc2! You've successfully authenticated, but GitHub does not provide shell access.

I couldn't find one of the error messages anymore but when I tried to push into the acc2 it said something about denying access because of acc1 or something like that. Then I tried using clone by ssh url and couldn't even clone any of these two accounts from github.

Now when I try to clone/push/pull I only get such error message Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Can someone please give me a hand?

Dora
  • 6,776
  • 14
  • 51
  • 99
  • Are you using the enterprise edition of Github by any chance? Can your friend's account see the github repo through their web view? – Martin Konecny Oct 28 '14 at 00:35
  • nope it's not enterprise edition because it's free and I created the other account for me and him to work together. yes I can view the repo using a browser. We were trying out pull/push/clone few days ago with his and my laptop and was fine but now I am using my desktop and this issue came up. All using windows – Dora Oct 28 '14 at 00:39

1 Answers1

0

The problem is because for public repositories, you need change your workflow a little bit. Your friend will need to fork your repository, and with this repository they can make any changes they wish.

Afterwards, when you are ready to combine your work, your friend will need to create a "pull request", where you review the code and decide to accept the changes into your own repository. This is the Github model for public collaboration.

Alternatively, you can go into "Settings" for your repository, and add your friend as a collaborator. He should then be able to commit changes directly to your repository.

Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
  • so this problem wouldn't exist if I am only working with one github instead of two? because somehow he pushed but when I'm doing it in my desktop today and the error happens but let me try going to the settings of the repository and see if I know how to set this up and try. – Dora Oct 28 '14 at 06:32
  • also I thought setting the config file so switching between account works. and I just added the collaborator and same error still exists – Dora Oct 28 '14 at 06:37
  • ok this is weird, somehow I reset all the ssh back to the original one and not having two ssh keys in `.ssh` folder anymore and somehow clone and push works now....@_@ – Dora Oct 28 '14 at 07:03