Windows 上 Git Bash 中的 X 会话?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10129267/
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
X session in Git Bash on Windows?
提问by user1271772
I'm using Git Bash on Windows. I have used Git Bash to SSH into a UNIX machine and tried to run a program with a GUI. I got the message: LINUX/UNIX system detected, but unable to access X11 display.
我在 Windows 上使用 Git Bash。我已经使用 Git Bash 通过 SSH 连接到 UNIX 机器并尝试使用 GUI 运行程序。我收到消息:检测到 LINUX/UNIX 系统,但无法访问 X11 显示。
I have X-Win 32 (commercial). I've also used Xming which is like a free version of X-Win 32 but has problems with certain graphics.
我有 X-Win 32(商业版)。我还使用过 Xming,它类似于 X-Win 32 的免费版本,但在某些图形上存在问题。
Is there a way I can get this remote system to access my X11 display through X-Win 32 or Xming or through any way ?
有没有办法让这个远程系统通过 X-Win 32 或 Xming 或通过任何方式访问我的 X11 显示器?
I'd just like to run programs like MATLAB, with a GUI popping up, from UNIX machines, when SSH'ed into that machine via Git Bash on Windows.
我只想在 UNIX 机器上运行像 MATLAB 这样的程序,当通过 Windows 上的 Git Bash SSH 连接到那台机器时,会弹出一个 GUI。
I also have PuTTY and Secure Shell Client installed, but would prefer to work exclusively form Git Bash because it requires less buttons to press in order to ssh to other machines.
我还安装了 PuTTY 和 Secure Shell Client,但更喜欢只从 Git Bash 工作,因为它需要更少的按钮来按 ssh 到其他机器。
If it's impossible to get this working on Git Bash I'd like to get it working with PuTTY (Secure Shell Client is good but has discontinued updates permanently).
如果不可能在 Git Bash 上使用它,我希望它与 PuTTY 一起使用(Secure Shell Client 很好,但已永久停止更新)。
回答by Stefan N?we
This Q is rather old, but anyway...
I was (at last...) able to get this working using the ssh
command from Git for Windows
and XMing
. All I had to do was to set the DISPLAY
environment variable to localhost:0.0
(it was set to only :0.0
).
这个 Q 相当旧,但无论如何......我(终于......)能够使用ssh
来自Git for Windows
和的命令使其工作XMing
。我所要做的就是将DISPLAY
环境变量设置为localhost:0.0
(设置为 only :0.0
)。
回答by Peng Bai
An alternative to Xming is VcXsrvbuilt using Visual Studio C++. The latest version of Xming now requires a donation.
Xming 的替代方案是使用 Visual Studio C++ 构建的VcXsrv。最新版本的 Xming 现在需要捐赠。
Point your mouse to the X icon in the status bar, and find out what port it runs on. If it is :0.0
(or :25.0
), then in Git Bash: export DISPLAY=localhost:0.0
(or export DISPLAY=localhost:25.0
). You may also need to use -Y
instead of -X
to your ssh command.
将鼠标指向状态栏中的 X 图标,然后找出它在哪个端口上运行。如果是:0.0
(或:25.0
),则在 Git Bash 中:(export DISPLAY=localhost:0.0
或export DISPLAY=localhost:25.0
)。您可能还需要使用-Y
代替-X
ssh 命令。
回答by will stone
I was able to accomplish this using putty and xming http://sourceforge.net/projects/xming/
我能够使用腻子和 xming http://sourceforge.net/projects/xming/
Simply start xming and enable x session forwarding in putty's options.
只需启动 xming 并在 putty 的选项中启用 x 会话转发。
回答by boretom
You have to start the X server before you connect using SSH. And when you connect to the other box you'll have to include the -X
switch with SSH. That'll tell SSH to forward X11 apps output to your Windows box.
在使用 SSH 连接之前,您必须启动 X 服务器。当您连接到另一个盒子时,您必须将-X
交换机包含在SSH 中。这将告诉 SSH 将 X11 应用程序输出转发到您的 Windows 机器。
回答by datenwolf
Your problem is, that you somehow have to carry over the XAuthority data to the remote host. Normally SSH does this for you, but only if it's started with the right environment variables. Basically you need to figure out the location of the xauth data and put that path into the XAUTHORITY environment variable. The DISPLAY is most likely ":0.0".
您的问题是,您必须以某种方式将 XAuthority 数据传输到远程主机。通常 SSH 会为您执行此操作,但前提是它以正确的环境变量启动。基本上,您需要找出 xauth 数据的位置并将该路径放入 XAUTHORITY 环境变量中。显示很可能是“:0.0”。
I think the most straightforward solution was using Cygwin and the X11 server it ships, because the X startup script of it will open a xterm from which you can SSH to the remote machine.
我认为最直接的解决方案是使用 Cygwin 及其附带的 X11 服务器,因为它的 X 启动脚本将打开一个 xterm,您可以从中通过 SSH 连接到远程机器。
回答by Hans Lawrenz
You can try adding the -X switch to your ssh command in git bash. I'm not sure if this will work. However, it's not the method I would suggest. Instead, I would suggest that you look into X forwarding using putty. You should be able to find a variety of guides on how to set this up with a quick search.
您可以尝试在 git bash 中将 -X 开关添加到您的 ssh 命令。我不确定这是否有效。但是,这不是我建议的方法。相反,我建议您使用 putty 研究 X 转发。您应该能够通过快速搜索找到有关如何进行设置的各种指南。