7

I have centos 6.4 running on VirtualBox. I can connect to it via putty just fine. However X11 forwarding is not working. I Have Xming 6.9.0.31 running and putty 0.62 is setup for X11 forwarding:

Putty and Xming

However, when I connect DISPLAY is not set:

[jdearing@njlt0151 ~]$ echo $DISPLAY

[jdearing@njlt0151 ~]$

And launching terminator fails

[jdearing@njlt0151 ~]$ terminator
Traceback (most recent call last):
  File "/usr/bin/terminator", line 30, in <module>
    import gtk, pango, gobject
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
    _init()
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
    _gtk.init_check()
RuntimeError: could not open display
[jdearing@njlt0151 ~]$

What am I doing wrong?

12

To get X11 forwarding working I needed to execute yum install xauth. At that point Terminator didn't render the console font properly. I was not particularly concerned about having a minimal set of fonts so I did yum -y groupinstall fonts and restarted terminator. The fonts rendered properly.

  • yum install xauth did it for me – davejal Nov 29 '18 at 13:30
3

You need to set the X local display to "localhost:0" in that text box.

                ss of putty

Necessary to set the display?

Typically you shouldn't need to set anything in that box, the "Enable X11 forwarding" is synonymous to setting the -X switch when you ssh from the terminal. But some X servers such as Xming and Exceed do not carry the display forward in certain cases, so setting it explicitly guards against that.

References

  • I actually didn't need to do this. The wording of that page You can enter localhost implies setting the display is optional. I'm sure setting the display becomes necessary in environments where you are forwarding to third party X servers. – Justin Dearing May 17 '13 at 13:49
  • 1
    Agreed, typically you shouldn't need to set anything in that box, the "Enable X11 forwarding" is synonymous to setting the -X switch when you ssh from the terminal. But some X servers such as Xming and Exceed do not carry the display forward in certain cases, so setting it explicitly guards against that. – slm May 17 '13 at 14:00
2

The way I'm doing this is (on Debian) for servers (i.e. a minimal X install) is via the 'xvfb' package, which is a "fake" virtual framebuffer X server for X.Org. It's also necessary to install the 'xauth' and 'xterm' packages. I'm pretty sure everything else installed is to satisfy dependencies of these. After doing that, running 'xterm' works through ssh (as should any other GUI program).

I haven't tried using X forwarding through putty (I don't normally run Windows) yet but if I remember I'll try doing that sometime.

1

I was encountering a similar issue, this evening. Similarly, I'm running Virtualbox on a Microsoft Windows Host OS. The Guest OS I'm using is Kubuntu, but of course the configuration between each of XMing, PuTTY, and Virtualbox would be similar. Though my reply is a little belated, maybe it'll be of help.

This solution was made with a VirtualBox virtual appliance publishing a NAT type network interface adapter to the host OS. For other network interface adapaters, the configuration might differ.

Using the NAT adapter, this configuration requires the IP address of that adapter, on the Microsoft Windows side. That address may be determined in the Windows Explorer shell, via the *Network and Sharing Center" window, in which one would 'click' on the _Virtualbox Host-Only Network adapter_. In the resulting 'Status' window, then after selecting the 'Details' button, the IPv4 address for the Virtualbox host-only network interface -- on the Microsoft windows side of the interface -- will be displayed in that status window. On my PC, the address is 192.168.50.1.

If should the IP address collide with other network devices, the IP address can be changed, via the 'Properties' window -- as available from the same 'Status' window -- then selecting the IPv4 item, and the 'Properties' button, then entering a different IP address. Of course, the Virtualbox virtual appliance should not be running when the address is changed, or Windows might not correctly propagate the address change for that interface.

So, having determined the IP address on the Windows side of the adapter, then one may run the VirtualBox Qt GUI, to add a port forwarding rule for the same virtual appliance in Virtualbox. I'm sure that there's a convenient shell command that could be used for adding the port forwarding rule with VBoxManage, alternately. Of course, the GUI configuration is rather straightforward, too.

The port forwarding change, in the respective Virtualbox virtual appliance, can be made via the 'Networking' page under the virtual appliance's Settings dialogue window. The button, 'Port Forwarding' displays a simple configuration window for the port forwarding rules, in the respective virtual appliance.

Adding a new port forwarding rule for the SSH config, the IP address that was determined from the adapter, in the Microsoft Windows guest OS, that address would be entered as the 'Host IP' address. An arbitrary port number above 1024 would be entered as the 'host port' for the port forwarding rule. Then, then the SSH server's port within the virtual appliance --- typically, 22 -- that would be added as the 'Guest port' for the port forwarding rule. Personally, I've left the 'Guest IP' field blank, and it works out just as well.

So, that would have served to configure Virtualbox to allow an SSH connection from the host PC to the guest OS. (Of course, one might wish to assume that that should not be necessary, when the NAT host-only adapter is selected. Apparently, the port forwarding rule is needed even with the NAT network adapter type) The configuration can be tested out using a regular Putty session, e.g to 192.168.50.1:2222

I've used Xlaunch in my own configuration. Evidently, the configuration as created with Xlaunch would serve to ensure that XMing would manage the X11 part of the port forwarding, as when Xming would thus be configured to use PuTTY or SSH. I've not interacted directly with PuTTY, in this much of the configuration.

Simply, when using Xlaunch for the Xming configuration: Then, in the last page of of the configuration dialogue window, in Xlaunch, one must enter the "host port" from the port forwarding rule, along with the appropriate command line argument for PuTTY or SSH, e.g. "-P 2222" without the quotes, of course. That would go into the "Additional parameters for PuTTY or SSH" field in the Xlaunch configuration window. In the resulting dot-xlaunch XML file, it shows up as ExtraSSH="-P 2222"

Then, "It just works," LoL. Of course, if a network interface adapter other than NAT would be selected in the virtual appliance's settings, then the successful configuration might differ widely from that denoted here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.