我在两种情况下使用git:
- 我用一些Github存储库。
- 我目前正在使用 OpenShift,它使用ssh and git用于部署。
首先,我用了ssh-keygen
用于生成在 OpenShift 站点更新的密钥。这样的密钥存储在~/.ssh/
并创造了id_rsa
and id_rsa.pub
.
然后我开始从 Github 克隆一个存储库,我曾经这样做过ssh-keygen
再次开始推动,效果很好。然后我克隆了另一个存储库并开始遇到问题:
克隆到第二个存储库时遇到问题。每次我尝试推动时都会显示类似以下内容:
ERROR: Permission to diegoaguilar/cursoJava.git denied to diegoaguilar/cursoCannibalCreatures.
fatal: The remote end hung up unexpectedly
但正如可以看到的diegoaguilar/cursoCannibalCreatures
不正确,因为它是another存储库。
我什至尝试删除这样的存储库目录,然后再次克隆它,同样的情况发生了。
我已经下了~/.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
于是得到:
id_cannibal id_cannibal.pub id_java id_java.pub known_hosts
就像是id_openshift
and id_openshift.pub
不存在,但由于它不起作用,所以我现在不太关心。
我创建了这样的文件,它们是.pub
by ssh-keygen -f <filename>
并为每个人提供了不同的密码短语。我添加了内容.pub
作为每个 Github 存储库设置中的部署密钥。
我究竟做错了什么?这应该如何运作?并且,当在另一台机器上工作时,如何正确获取这些密钥,证明是我的并且透明地工作?
EDIT
输出git remote -v
:
origin [email protected] /cdn-cgi/l/email-protection:diegoaguilar/cursoJava.git (fetch)
origin [email protected] /cdn-cgi/l/email-protection:diegoaguilar/cursoJava.git (push)
- 对于 cursoCannibalCreatures
origin [email protected] /cdn-cgi/l/email-protection:diegoaguilar/cursoCannibalCreatures.git (fetch)
origin [email protected] /cdn-cgi/l/email-protection:diegoaguilar/cursoCannibalCreatures.git (push)