Howto: Setup Multiple Nested X Sessions in Ubuntu

What is Xephyr ?

Xephyr is a X server that runs as a small window within your current X session.

What is it good for ?

There are multiple potential uses for Xephyr:

  • Development. You can ssh into a chroot and forward X sessions.
  • Forward X over ssh without VNC.

Example: Normally if you ssh -X you can forward x applications. This is not a problem if you are forwarding a single application from a single server. But if you forward multiple applications from multiple servers or a whole desktop, it gets messy (to say the least). You can start a new X session ( Virtual X ), but then you have to Ctl-Al-F7 and Ctrl-Alt-F8 between them.

1. Install Xephyr

Code:

sudo apt-get install xserver-xephyr
2. Start Xephyr

Code:

Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &
  • The ":1" = your display (displays are numbered starting with 0)
  • -ac = disable access control restrictions= allow you to forward X
  • -screen 1280x1024 = screen size
  • -br = black background
  • -reset -terminate= Xephyr should automatically close when the last X client is killed, does not always work.
  • 2> /dev/null redirects error messages.

3. Set your display (for X)

Code:

DISPLAY=:1.0
  • Don't forget to set it back after you establish a ssh connection ( DISPLAY=0.0 )

=========================


4. Forward single apps / separate window for each server.

Start Xephyr

Code:

Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &
Change your $Display

Code:

DISPLAY=:1.0
Forward a xterm:

Code:

ssh -XfC -c blowfish user@server xterm
  • -X = forward X
  • -f = puts your ssh session into the background
  • -C = use compression -c blowfish = use blowfish (I am told this is the fastest)

Any X apps for that server will start in that window.


=========================


5. Desktop:

Start Xephyr

Code:

Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :2 &
2. ssh into the chroot/server

Code:

ssh -XfC -c blowfish user@server xfce4-session
  • Substitute your window manager for "xfce4-session"


=========================

Clicky Web Analytics