Difference between revisions of "X inside VE"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
m (minor rewording here and there)
Line 1: Line 1:
= running X applications inside VE =
+
There are several ways to run X applications inside your [[VE]].
  
To run application inside VE one need simply to connect to VE with '''ssh -X''':
+
== X forwarding ==
 +
 
 +
To run an X application inside a [[VE]], one need simply to connect to a VE with '''ssh -X''':
 
<pre>
 
<pre>
 
host# ssh -X user@address
 
host# ssh -X user@address
 
</pre>
 
</pre>
  
After login to VE check that $DISPLAY variable is set and X11 forwarding is enabled:
+
After login to VE check that <code>$DISPLAY</code> variable is set and X11 forwarding is enabled:
 
<pre>
 
<pre>
 
vps# echo $DISPLAY
 
vps# echo $DISPLAY
Line 12: Line 14:
 
</pre>
 
</pre>
  
if $DISPLAY is not set, make sure that X forwarding is enabled in sshd config inside VE.
+
In case <code>$DISPLAY</code> is not set, make sure that X forwarding is enabled in <code>sshd</code> config inside VE. In most Linux distros sshd configuration is stored in <code>/etc/ssh/sshd_config</code>. You should set parameter <code>X11Forwarding</code> to <code>yes</code>. After that, restart your sshd daemon:
<br>In most Linux distros sshd config can be found at '''/etc/ssh/sshd_config'''.
 
Set variable '''X11Forwarding''' to 'yes' and restart your sshd daemon:
 
 
<pre>
 
<pre>
 
vps# /etc/init.d/sshd restart
 
vps# /etc/init.d/sshd restart
 
</pre>
 
</pre>
  
Don't forget to reconnect after this.
+
{{Note|Don't forget to reconnect after this}}
  
 
Now you can run X applications from your VE:
 
Now you can run X applications from your VE:
Line 26: Line 26:
 
</pre>
 
</pre>
  
== Using VNC for X desktop ==
+
== VNC for X desktop ==
 
First, one need to run '''Xvnc''' server inside VE. The easiest way for this is to run
 
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
 
'''vncserver''' script. This scripts starts all the required services
Line 45: Line 45:
 
</pre>
 
</pre>
  
== Starting KDE desktop with VNC ==
+
=== Starting KDE desktop with VNC ===
 
To start KDE desktop instead of default twm one replace 'twm &' line with 'startkde &' in user
 
To start KDE desktop instead of default twm one replace 'twm &' line with 'startkde &' in user
 
~/.vnc/xstartup file.
 
~/.vnc/xstartup file.
  
== Connecting with VNC from firewalled network ==
+
=== Connecting with VNC from firewalled network ===
 
VNC uses 590x TCP ports for its connections. These ports can be firewalled in
 
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.
 
many networks so in order to be able to connect to remote side one need to tunnel VNC connections somehow.
Line 83: Line 83:
  
 
[[Category: HOWTO]]
 
[[Category: HOWTO]]
 +
[[Category: Networking]]

Revision as of 15:23, 28 June 2006

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

X forwarding

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

host# ssh -X user@address

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

vps# 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. After that, restart your sshd daemon:

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

Now you can run X applications from your VE:

vps# firefox

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

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

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

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

host# vncviewer <vpsip>:1

Starting KDE desktop with VNC

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

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 usuall 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 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