I use git under two scenarios:
- I use some Github repositories.
- I'm currently working with OpenShift, which uses ssh and git for deployment.
First, I used ssh-keygen
for generating a key which updated at OpenShift site. Such key is stored at ~/.ssh/
and created id_rsa
and id_rsa.pub
.
Then I started cloning a repository from Github, I once did ssh-keygen
again and started pushing, it worked ok. Then I cloned another repository and started having problems:
I got problems when cloning to the second repository. Every time I try to push will show something like:
ERROR: Permission to diegoaguilar/cursoJava.git denied to diegoaguilar/cursoCannibalCreatures. fatal: The remote end hung up unexpectedly
But as it can be seen diegoaguilar/cursoCannibalCreatures
isn't correct as it's another repository.
I even tried removing such repository directory, and cloning it again, same happened.
I already got under ~/.ssh
:
config
:
Host cursoJava
Hostname github.com
User git
IdentityFile ~/.ssh/id_java
Host cursoCannibalCreatures
Hostname github.com
User git
IdentityFile ~/.ssh/id_cannibal
Host openshift
Hostname openshift.com
User git
IdentityFile ~/.ssh/openshift
And so got:
id_cannibal id_cannibal.pub id_java id_java.pub known_hosts
Something like id_openshift
and id_openshift.pub
isn't there but as it's not working, I don't care much now.
I created such files and they're .pub
by ssh-keygen -f <filename>
and gave different pass phrases to each. I added the content of the .pub
's as deploy keys at each Github repository settings.
What am I doing wrong? How is this supposed to work? And, when working at another machine, how to properly obtain these keys, proof it's me and work transparently?
EDIT
Output of git remote -v
:
- For cursoJava repository
origin git@github.com:diegoaguilar/cursoJava.git (fetch)
origin git@github.com:diegoaguilar/cursoJava.git (push)
- For cursoCannibalCreatures
origin git@github.com:diegoaguilar/cursoCannibalCreatures.git (fetch)
origin git@github.com:diegoaguilar/cursoCannibalCreatures.git (push)