Open main menu

OpenVZ Virtuozzo Containers Wiki β

X inside VE

Revision as of 21:07, 22 November 2007 by Bodhi.zazen (talk | contribs) (Xephyr)

There are several ways to run X applications inside your VE.

Contents

X forwarding

Single application

To run an X application inside a VE, one need simply to connect to a VE with ssh -X:

host# ssh -2 -c blowfish -X user@address

After login to VE check that $DISPLAY variable is set and X11 forwarding is enabled:

ve# echo $DISPLAY
localhost:10.0

In case $DISPLAY is not set, make sure that X forwarding is enabled in sshd config inside VE. In most Linux distros sshd configuration is stored in /etc/ssh/sshd_config. You should set parameter X11Forwarding to yes. Also VE should contain xauth package, thus install xauth if it is missing (in Debian this is part of the xbase-clients package). After that, restart your sshd daemon:

ve# /etc/init.d/sshd restart
  Note: Don't forget to reconnect after this

Now you can run X applications from your VE:

ve# firefox

Desktop

Note : If you want to run complete X window environment (including window manager), you should kill local window manager and run only pure X server. Secondly you should use -Y option when invoking ssh. And if you want to run gnome/kde/..., don't forget to increase UBC limits, 'cause default values are certainly too small for these monsters. ;)

You can run a desktop with xinit (on the node):

xinit -e ssh -XCc blowfish user@ip_address "/usr/bin/xfce4-session &" -- :1 & disown
  • Substitute the window manager of choice
  • Once xfce has started, you can then close the xterm if you like


Your node will be on Ctrl-Alt-F7

And your VM on Ctrl-Alt-F8

VNC for X desktop

First, one need to run Xvnc server inside VE. The easiest way for this is to run vncserver script. This scripts starts all the required services and small http daemon which provides graphical web access to your desktop (via Java applet).

ve# vncserver -name mydesktop
New 'mydekstop' desktop is ve:1

Starting applications specified in ~/.vnc/xstartup
Log file is ~/.vnc/ve:1.log

Now when your desktop is up and running you can connect to it using vncviewer command:

host# vncviewer <VE_IP>:1

If the VNC desktop is the same size or larger than your X desktop, you will see scroll bars on the bottom and the side. This is often inconvenient. You may reduce your VNC desktop to a more reasonable size like this:

vncserver -geometry 1000x650

This setting works quite well for a 1024 by 768 X desktop setting.

Starting KDE desktop with VNC

To start KDE desktop instead of default twm one replace twm & line with startkde & in user's ~/.vnc/xstartup file on the VE.

Connecting with VNC from firewalled network

VNC uses 590x TCP ports for its connections. These ports can be firewalled in many networks so in order to be able to connect to remote side one need to tunnel VNC connections somehow. A usual ssh can be used for tunneling VNC connections as described below.

localhost# ssh -L 5900:localhost:5900 <remote host>

where <remote host> is the name of the system you want to connect to. When you are asked for a username and password enter your normal username and password. Then start the VNC session to localhost, i.e.

localhost# vncviewer localhost

Using Xephyr

Xephyr gives you nested X windows.

First, install Xephyr on your host.

Start Xephyr

Xephyr -ac -screen 1280x1024 -br -reset -terminate :1 &

Change your display settings (don't forget to change them back after you establish a connection)

DISPLAY=:1,0

Forward your application or desktop over ssh to Xephyr

ssh -XfC -c blowfish user@server xfce4-session

If you use an alternate window manager, substitute "startkde", "gnome-session", "startfluxbox", etc. as needed.

Screenshot

Using xdm

It should be also possible to do remote X by running xdm inside VE and X -query <remote IP> :1

However VNC approach is much easier.

External links