git 产生 Gtk-WARNING: 无法打开显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16077971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git produces Gtk-WARNING: cannot open display
提问by John Manak
I've been working on my project remotely through the command line on a machine to which I don't have admin rights and after running git push origin master
I get the following error message:
我一直在我没有管理员权限的机器上通过命令行远程处理我的项目,运行后git push origin master
我收到以下错误消息:
(gnome-ssh-askpass:29241): Gtk-WARNING **: cannot open display:
My .git/config
file has the following contents:
我的.git/config
文件有以下内容:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = https://[email protected]/username/repository.git [branch "master"] remote = origin merge = refs/heads/master
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = https://[email protected]/username/repository.git [branch "master"] remote = origin merge = refs/heads/master
I was getting the 403 error earlier. Following the comment here, I put my username before the @ sign in the remote url and since then, I've been getting the Gtk error.
我之前收到了 403 错误。按照此处的评论,我将我的用户名放在远程 url 中的 @ 符号之前,从那时起,我一直收到 Gtk 错误。
When I login to the machine using ssh -X
and try to push, I get the following error:
当我使用登录机器ssh -X
并尝试推送时,出现以下错误:
X11 connection rejected because of wrong authentication.
(gnome-ssh-askpass:31922): Gtk-WARNING **: cannot open display:localhost:10.0
If I change the url of the remote to [email protected]:username/repository.git
, then the error is:
如果我将遥控器的 url 更改为[email protected]:username/repository.git
,则错误为:
ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly
Do you know how to fix this?
你知道如何解决这个问题吗?
回答by John Manak
I have finally discovered a solution to the problem. As it was described here, I ran the following command in the terminal:
我终于找到了解决问题的方法。正如此处所述,我在终端中运行了以下命令:
unset SSH_ASKPASS
and then running git push origin master
works the way it should. You can also add the line to your .bashrc
file.
然后运行git push origin master
它应该的方式。您还可以将该行添加到您的.bashrc
文件中。
回答by eikonomega
I recently dealt with this behavior on a RedHat 5 machine where our Git version was 1.7.4.1.
我最近在我们的 Git 版本为 1.7.4.1 的 RedHat 5 机器上处理了这种行为。
I didn't have a high degree of confidence that unset SSH_ASKPASS
wouldn't have unintended consequences, so I wanted to see if there was another solution.
我没有高度的信心unset SSH_ASKPASS
不会产生意想不到的后果,所以我想看看是否有其他解决方案。
I couldn't tell for certain, but it seems that a patch for this problem was in the worksaround the same time that our version of Git had been published. So, it seemed to me that it was reasonable to hope that a more recent version would correct the behavior.
我不能确定,但似乎在我们的 Git 版本发布的同时,针对这个问题的补丁正在开发中。因此,在我看来,希望更新的版本能够纠正这种行为是合理的。
And indeed it did. Upgrading to the 1.8 branch of Git resolved the problem.The error message is still displayed for some odd reason, but you are correctly prompted for your password and allowed to continue.
确实如此。升级到 Git 的 1.8 分支解决了这个问题。由于某些奇怪的原因仍会显示错误消息,但系统会正确提示您输入密码并允许继续。
回答by johnsimer
None of these answers worked for me (ssh'ing via Cygwin on Windows 10 into a RHEL 6.8 server and trying to clone a github.com repo from the RHEL box) so what I did was clone via an SSH key rather than HTTPS username/password. e.g. I used [email protected]:MyUsername/myproject.git rather than the https url. I also appropriately uploaded my public key into Github. This method worked fine.
这些答案都不适合我(通过 Windows 10 上的 Cygwin ssh'ing 到 RHEL 6.8 服务器并尝试从 RHEL 框中克隆 github.com 存储库)所以我所做的是通过 SSH 密钥而不是 HTTPS 用户名/密码。例如,我使用 [email protected]:MyUsername/myproject.git 而不是 https url。我还适当地将我的公钥上传到了 Github。这种方法效果很好。
Note: Of the above solutions, I actually didn't try upgrading to the 1.8 branch of git
注意:以上解决方案中,我实际上并没有尝试升级到 git 的 1.8 分支
回答by cr_dave
You can also try to login using ssh -Y to the remote server so the dialogue box can appear graphically.
您还可以尝试使用 ssh -Y 登录到远程服务器,以便以图形方式显示对话框。
Like the OP, logging in via ssh -X didn't work. When trying to push, the server simply repeated the same error message - (gnome-ssh-askpass:29241): Gtk-WARNING **: cannot open display:
- as it did when logging via ssh with no X11 forwarding. This is slightly different behavior from what the OP reported when he tried ssh -X as his error message changed slightly from just using ssh.
与 OP 一样,通过 ssh -X 登录不起作用。尝试推送时,服务器只是重复了相同的错误消息(gnome-ssh-askpass:29241): Gtk-WARNING **: cannot open display:
——就像通过 ssh 登录时没有 X11 转发时所做的那样。这与 OP 在尝试 ssh -X 时报告的行为略有不同,因为他的错误消息与仅使用 ssh 略有不同。
However, for me, once logged in using ssh -Y: there was no error, the password dialogue box popped up, I typed the password in, and GitHub accepted the push.
但是,对我来说,一旦使用ssh -Y登录:没有错误,弹出密码对话框,我输入密码,GitHub接受推送。
As a forewarning, ssh -Y can open up security problems as you are treating the remote server as a trusted client (https://askubuntu.com/questions/35512/what-is-the-difference-between-ssh-y-trusted-x11-forwarding-and-ssh-x-u). So be careful when using it.
作为预警, ssh -Y 可以打开安全问题,因为您将远程服务器视为受信任的客户端(https://askubuntu.com/questions/35512/what-is-the-difference-between-ssh-y-信任-x11-forwarding-and-ssh-xu)。所以使用时要小心。