Git推送在GNU屏幕内失败

Jon*_*tke 7 git gnu-screen github public-key

我可以从我的VPS推送到我的GitHub仓库,但是一旦我进入屏幕,我就会被拒绝许可:

littke@[server]:~/src/[repo]$ git push
Pushing to git@github.com:littke/[repo].git
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

即使我能够认证:

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.
Run Code Online (Sandbox Code Playgroud)

同样,这只发生在GNU屏幕内部.我可以在它外面推得很好.我用谷歌搜索但无法找到任何东西.

Fre*_*urk 4

您在 ssh 中使用的身份文件(-i 选项)与 git 使用的身份文件不同。您必须通过您的配置告诉 git 使用哪个身份。请参阅 github 的Troubleshooting SSH issues 的“SSH 配置”部分:

在 ~/.ssh/config 创建或打开文件添加以下行:

Host github.com
  User git
  Hostname github.com
  PreferredAuthentications publickey
  IdentityFile [local path]
Run Code Online (Sandbox Code Playgroud)

  • 如果我通过 VPS 连接,而我只将密钥转发到该 VPS(`ssh -a`),该怎么办?无法指定身份文件,可以吗? (2认同)