【问题标题】:Git push fails within GNU screenGit 推送在 GNU 屏幕中失败
【发布时间】:2011-08-24 17:43:03
【问题描述】:

我可以从我的 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

即使我能够验证:

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 屏幕中。我可以很好地推开它。我用谷歌搜索,但找不到任何东西。

【问题讨论】:

    标签: git github public-key gnu-screen


    【解决方案1】:

    需要设置一些额外的位以使 SSH 代理转发在屏幕中工作。请查看How do you get screen to automatically connect to the current ssh-agent when re-attaching to an existing screen? 了解详情。

    【讨论】:

      【解决方案2】:

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

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

      Host github.com
        User git
        Hostname github.com
        PreferredAuthentications publickey
        IdentityFile [local path]
      

      【讨论】:

      • 这行得通,谢谢!为什么它可以在屏幕之外工作呢?
      • @JonatanLittke:可能存在与环境变量的交互或您没有注意到的其他差异。
      • 可能是这样!这意味着这也很可能是答案。但这行得通。
      • 如果我通过我的 VPS 连接,我只转发了我的密钥 (ssh -a)。无法指定身份文件,可以吗?
      【解决方案3】:

      -i 正在强制 ssh 使用不同的密钥。当您尝试使用 git 时,ssh 不知道该密钥。尝试改用默认密钥名称,或 ssh-add 密钥,以便 ssh 知道。

      【讨论】:

      • 我在屏幕上运行ssh-add,得到Could not open a connection to your authentication agent.。这大概和push不起作用有关吧?
      • 可能。听起来屏幕会话无法与 ssh-agent...听起来上面的答案对你有用,所以我会这样做。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-16
      • 1970-01-01
      • 2013-03-17
      • 2018-05-02
      • 1970-01-01
      • 2013-01-26
      相关资源
      最近更新 更多