我可以很好地从我的 VPS 推送到我的 GitHub 存储库,但是一旦我进入一个 screen ,我的权限就被拒绝了:
littke@[server]:~/src/[repo]$ git push
Pushing to git@github.com:littke/[repo].git
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
即使我能够授权:
littke@[server}:~/src/[repo]$ ssh git@github.com -i ~/.ssh/littke
Enter passphrase for key '/home/littke/.ssh/littke':
PTY allocation request failed on channel 0
Hi littke! You've successfully authenticated, but GitHub does not provide shell access.
同样,这只发生在 GNU screen 内。我可以把它推到外面。我用谷歌搜索但找不到任何东西。
最佳答案
您在 ssh(-i 选项)中使用的身份文件与 git 使用的身份文件不同。你必须通过你的配置告诉 git 使用哪个身份。参见 github 的 Troubleshooting SSH issues ,“SSH 配置”部分:
Create or open the file at ~/.ssh/config Add the following lines:
Host github.com User git Hostname github.com PreferredAuthentications publickey IdentityFile [local path]
关于GNU screen 中的 Git 推送失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5988897/