X session in Git Bash on Windows?

可紊 提交于 2020-06-10 08:03:12

问题


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.

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.

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 ?

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.

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.

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).


回答1:


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).




回答2:


An alternative to Xming is VcXsrv built using Visual Studio C++. The latest version of Xming now requires a donation.

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.




回答3:


I was able to accomplish this using putty and xming http://sourceforge.net/projects/xming/

Simply start xming and enable x session forwarding in putty's options.




回答4:


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.




回答5:


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.




回答6:


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".

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.



来源:https://stackoverflow.com/questions/10129267/x-session-in-git-bash-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!