Saturday, October 4, 2008

Multiple Desktops in Linux (even Remote ones...)

Although I love the ability to control Linux PCs and servers remotely with ssh and X tunneling, I was never satisfied with VNC as a complete Remote Desktop solution. For starters it is insecure and to secure it you have to jump through a couple hoops. The biggest problem, however, is that you already have to have a session running on the remote computer in order to use VNC.

I wanted an easy to use, built-in, secure way to get a complete remote desktop on a Linux machine at any time, from anywhere.

Luckily I found one:

1) go to a new terminal via ctrl-alt-f2 and login.
2) type "xinit -- :1". This should pop up a new instance of x with a terminal running. I had to mouse over the terminal to type.
3) type "ssh -CX user@host" and login to the remote server (C is compression...)
4) now type "gnome-session" or "startkde" or whatever desktop you want to start.

Thats it. No special programs and it is already encrypted through an ssh tunnel =).

To close this desktop type "ctrl-alt-backspace".
To get back to your primary desktop type "ctrl-alt-f7".
To switch back to the remote desktop type "ctrl-alt-f9".

You can open another desktop if you would like even with these two open, just use "xinit -- :2" which will be on the f10 terminal... You can do as many as 5 or 6.


If you want another local, rather than remote, desktop you can just ignore the ssh step (3) and just start the new desktop locally. This will allow you to run kde, gnome, and xcfe side by side and switch between them with a single key combo.


Also, you may find it useful to know that many programs have a --desktop option that allows you to open programs on any desktop from any terminal. ie "firefox --desktop :1". If you have multiple monitors you can even do "firefox --desktop :1.1" to specify the second monitor.


If you want to do this from windows just use a program like Xming :). Although the beta xrdp project is kind of interesting, it still seems a bit rough around the edges. The only thing that this doesn't really allow you to do is resume already running sessions :/

Update: What I was looking for was Xephyr. Works like a charm: http://ubuntuforums.org/showthread.php?p=3816948#post3816948 (The whole terminal thing is still cool tho =p)

No comments: