无法推送到我的服务器上的git存储库

无法推送到我的服务器上的git存储库,git,github,ssh,Git,Github,Ssh,我想在我的服务器上有两个git存储库。其中一个属于其他人。我将他们的ssh密钥复制到我的帐户上: sudo cp /home/otheruser/.ssh/id_rsa id_rsa sudo cp /home/otheruser/.ssh/id_rsa.pub id_rsa.pub git clone git@github.com:otheruser/Gateway.git git remote show origin * remote origin Fetch URL: git@github

我想在我的服务器上有两个git存储库。其中一个属于其他人。我将他们的ssh密钥复制到我的帐户上:

sudo cp /home/otheruser/.ssh/id_rsa id_rsa
sudo cp /home/otheruser/.ssh/id_rsa.pub id_rsa.pub
git clone git@github.com:otheruser/Gateway.git
git remote show origin
* remote origin
Fetch URL: git@github.com:otheruser/Gateway.git
Push  URL: git@github.com:otheruser/Gateway.git
HEAD branch: master
Remote branches:
...
现在我想将其中一些分支复制到我自己的git帐户中:

git remote add tempgateway git@github.com:myuser/TemporaryGateway.git
git remote -v
origin  git@github.com:otheruser/Gateway.git (fetch)
origin  git@github.com:otheruser/Gateway.git (push)
tempgateway git@github.com:myuser/TemporaryGateway.git (fetch)
tempgateway git@github.com:myuser/TemporaryGateway.git (push)
但当我试图访问git存储库时,ssh身份验证似乎失败了:

git remote show tempgateway
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
因此,我生成ssh密钥:

ssh-keygen -t rsa -f ~/.ssh/tempgateway.id_rsa
ls -l
-rw------- 1 myuser myuser 1675 2014-01-02 15:39 id_rsa
-rw-r--r-- 1 myuser myuser  399 2014-01-02 15:41 id_rsa.pub
-rw-r--r-- 1 myuser myuser 1768 2014-01-02 16:22 known_hosts
-rw------- 1 myuser myuser 1679 2014-01-02 16:55 tempgateway.id_rsa
-rw-r--r-- 1 myuser myuser  401 2014-01-02 16:55 tempgateway.id_rsa.pub
然后添加配置文件并输入以下内容:

Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa

Host tempgateway.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/tempgateway.id_rsa
我添加到ssh中:

ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/tempgateway.id_rsa
ssh添加-l

2048 cb:cf:15:9d:6d:73:ac:d0:b2:8e:df:xx:xx:xx:xx:xx ~/.ssh/id_rsa (RSA)
2048 cd:f3:f8:2e:8d:53:3e:59:1b:38:68:xx:xx:xx:xx:xx ~/.ssh/tempgateway.id_rsa (RSA)
然后将tempgateway的公钥添加到我的github帐户

为了测试我是否正确地完成了这一切,我进行了以下检查:

ssh -T git@tempgateway.github.com
Hi MyUser! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T git@github.com
Hi OtherUser! You've successfully authenticated, but GitHub does not provide shell access.
现在,虽然我能够为origin显示remotes still,但当我尝试为tempgateway显示remotes时,我得到以下still:

git remote show tempgateway
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

git push tempgateway origin/master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

为什么我可以通过ssh连接到git存储库中,但我无法显示源代码或推送到它?

如果ssh访问正在工作,正如您所示,那么我将确保新的远程repo已正确初始化或复制。如果不是,那么吉特不会将其视为回购

编辑:

抱歉,我没有注意到您正在使用github。那么你就不必为上面的事操心了

但我确实注意到,在为这两个帐户使用不同的SSH密钥对时,在设置新的远程存储库时运行config命令时没有使用tempgateway.github.com。尝试编辑.git/config并使用在远程URL中创建的新SSH标识名

git remote-v命令的输出可能更像

tempgateway git@tempgateway.github.com:myuser/TemporaryGateway.git (fetch)
tempgateway git@tempgateway.github.com:myuser/TemporaryGateway.git (push)


运行git ls remote的结果是什么git@github.com:myuser/TemporaryGateway.git?错误:找不到存储库。致命:远程端意外挂起,这表明您需要向Github中的存储库授予对“MyUser”的访问权限。实际上,有两个MyUser。一个是存储库所在的github帐户的实际MyUser。另一个myuser只是一个ubuntu用户角色。对不起,我的意思是在github.com上,而不是在服务器上。您可以使用Github验证OK,因此它表明该用户访问该存储库时存在权限问题。但我不尝试使用文件初始化它。我想通过现有的仓库来回答你的问题,我运行了git remote add tempgatewaygit@github.com:myuser/TemporaryGateway.git然后我运行了git remote-v,它给了我这个:origingit@github.com:otheruser/Gateway.git获取来源git@github.com:otheruser/Gateway.git推送临时网关git@github.com:myuser/TemporaryGateway.git获取临时网关git@github.com:myuser/TemporaryGateway.git请检查您是否正在使用新的密钥对。我已经编辑了我的回复,以进一步阐述这一点。我明白你的意思。我怎样才能做到呢git@tempgateway.github.com而不是git@github.com
tempgateway git@github.com:myuser/TemporaryGateway.git (fetch)
tempgateway git@github.com:myuser/TemporaryGateway.git (push)