19

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

Nike
  • 1,223
  • 2
  • 19
  • 42
  • Two things: 1. You need to dissable access control in Xming (so `-ac`) [not recommended] and 2. You need to setup DISPLAY to point to the IP where Xming is running when trying to connect. – Stanislav May 22 '17 at 09:20

6 Answers6

19

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

Stefan Näwe
  • 3,040
  • 1
  • 18
  • 19
13

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.

P. B.
  • 417
  • 6
  • 12
  • I don't know where this "requires a donation" thing comes from. So far as I can tell, you just [download it from SourceForge](https://sourceforge.net/projects/xming/files/latest/download), install it and you're away. The [Terms on the Xming website](http://www.straightrunning.com/XmingNotes/terms.php) state that SourceForge releases are Public Domain. ("You can do what you like with Public Domain releases including freely distributing them; they still retain all original authors' licenses appropriately, but I have relinquished my rights over them.") – Jon Green Oct 11 '19 at 09:30
  • 1
    The last public domain release is from 2007. Check [here](http://www.straightrunning.com/XmingNotes/#head-12) to see where this "requires a donation" thing comes from. – P. B. Oct 12 '19 at 14:45
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.

mtvec
  • 17,846
  • 5
  • 52
  • 83
will stone
  • 31
  • 2
  • it works with git-bash and xming too, at least for `xclock`. just need to set the display to `localhost...` before `ssh`ing. – mulllhausen Apr 08 '16 at 04:17
1

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.

boretom
  • 121
  • 5
  • Thanks so much for your response. I tried: ssh -X name@server.corp.com and then xclock, and it said "error: Can't open display" – Nike Apr 13 '12 at 00:51
0

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.

Hans Lawrenz
  • 402
  • 2
  • 9
  • Thanks so much for your response. I tried: ssh -X name@server.corp.com and then xclock, and it said "error: Can't open display" . I was able to get xclock to work on the same server in PuTTY though by going to Connection->SSH->X11 and selecting "enable X11 tunelling" and setting the display location to 127.0.0.1:0 (ie, my own machine, on which PuTTY is running). Thanks for you advice. It would still be ideal to be able to do this from Git Bash - why do you not recommend it ? – Nike Apr 13 '12 at 00:56
  • I wouldn't recommend it because from what I understand git bash exists only to give you a handy command line for git on windows. Even if you could get it to work, I doubt X forwarding is on the developers radar. – Hans Lawrenz Apr 13 '12 at 14:27
0

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.

datenwolf
  • 159,371
  • 13
  • 185
  • 298