Thursday, December 28, 2006

Xubuntu Remote Desktop with VNC4Server

A thread on ubuntuforms.org , called "HOWTO: Set up VNC server with resumable sessions", described how to do something that I have been trying to do with Xubuntu for a while. Ubuntu remote desktop access is easier due to the inclusion of the vino-server. The thread went on for a number of pages and this post attempts to capture all of the bits relevant to getting this working on Xubuntu. This was done on a Fiesty Fawn installation, but should work on Edgy.

The objective is
  • to allow remote access to a Xubuntu desktop and,
  • in this case, this will be in the form of a resumable session, and
  • to not use any GNOME libraries.

  1. Install the required applications:
sudo apt-get install vnc4server xinetd xvnc4viewer
  1. If you do not already have it installed, install ssh, which should bring in the client and the server:
sudo apt-get install ssh
  1. Open the "Login Window" applet in the Applications --> Settings menu. You should be prompted for your password to access this.
  2. Choose the "Remote" tab and select one of the options from the Style dropdown. I select Plain.
  3. At the bottom of the tab, there is a button called "Configure XDMCP...". Click and make sure that the "Honor indirect requests" is NOT selected.
  4. Using your favourite text editor, open /etc/gdm/gdm.conf for editing. You will need superuser privileges, so it should be something like:
sudo vi /etc/gdm/gdm.conf
OR
sudo nano /etc/gdm/gdm.conf

EDIT: The preferred file to edit is gdm.conf-custom as changes made to this file will survive an upgrade of GDM. Of the changes below, you should only need to add the RemoteGreeter line under [daemon] and AllowRemoteRoot under [security]. The [xdmcp] items were already in place.
  1. In this file, in the [daemon] section, uncomment (i.e. remove the leading '#' sign) from the line which starts "RemoteGreeter=/usr/lib/gdm/gdmlogin".
  2. In the [security] section, I change the AllowRemoteRoot to false.
  3. In the [xdmcp] section, make sure Enable=true and HonorIndirect=false.
  4. Now, to create an entry for xinetd to start each time it receives a connect request, create a file called Xvnc in /etc/xinetd.d. In /etc/xinetd.d/Xvnc, put the following text:
service Xvnc
{
type = UNLISTED
disable = no
socket_type = stream
protocol = tcp
wait = yes
user = root
server = /usr/bin/Xvnc
server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd
port = 5901
}
EDIT: Important: The text starting at "server_args..." and ending at ".../root/.vncpassword" is all ONE line. If you cut-and-paste, it might paste it as multiple lines instead of one long line.

EDIT2: Add "-extension XFIXES" to the end of the "server_args" line to get past the End of Stream problem.

EDIT3: Also note that the default setting to allow multiple logins in GDM has changed. I had a follow up post about this, but anotherstuart pointed out that it was missing here. See comments. Thanks!

NOTE: The font path in the -fp argument is slightly different from what was in the original thread. If you search in launchpad.net, you'll find some bugs about this.

  1. Create a password for xinetd, by running
sudo vncpasswd /root/.vncpasswd
  1. Restart xinetd by running:
sudo /etc/init.d/xinetd stop
sudo killall Xvnc
sudo /etc/init.d/xinetd start
You may also need to reboot to get some of the other changes to take effect.

To test that it is working, either
  1. Use
xvnc4viewer :1
to start a session on the machine, or

  1. Connect from another machine using a client like tightvnc.

You should get a graphical login.

NOTE: The session created does not end if you terminate the connection. It persists until you actually log out. This is useful if you are on a connection that drops out or if you login to start a job and need to disconnect without killing the job.

Once this is working, you can also tunnel this over an ssh connection, depending on your required level of paranoia.

Technorati Tags: , , ,

54 comments:

Mike said...

Very helpful tutorial. Worked perfectly. Out of curiosity, is there any way to allow the remote connection to connect to the active session on the local desktop?

Warren Butler said...

Mike,

You can. The active desktop is terminal :0 and is run by the x.org X-server. On the other hand, vnc-type sessions are new sessions created and served by, for example, vnc4server and are :1, :2, etc.

To view :0, you will need to use x11vnc. Tichondrius' original thread contained lots of information and it is hidden in there.

Basically, you need to install x11vnc and create another xinetd file for it. x11vnc doesn't create a new session, but will serve the existing :0 session. I tried it an it works.

Note that if you do xvncviewer localhost:0 on the actual machine, you get into a loop of sessions. Like when you see mirrors in mirrors. Just kill the window.

Cheers

Warren

matthew said...
This post has been removed by the author.
matthew said...

This was a very informative tutorial, so thanks. I however, followed the directions to the letter and failed. But I'm more on my way than I've ever been with xubuntu, so thanks,,,, again.

Warren Butler said...

Matthew,

I have got this working on a number of different Xubuntu machines, so we should be able to solve any problems you have.

Can you give me an idea of what happens, or what the symptom is?

You can email me directly on [the name of this blog], which is at a gmail address.

Regards

Warren

Matthew said...
This post has been removed by the author.
Matthew said...

(different Matthew)
I'm failing too.

Using xvnc4viewer :1 (locally)
A window pops up, I'm asked the VNC Authentication [VncAuth] password, after entering anything (the correct or otherwise) I get the date/time printed and "main: End of stream"

Using realvnc (remotely)
I'm asked the session password and then no further window ever comes up.

Richard said...

I get the same as Differnet MAthew above, brand new insatll of latest xubuntu.
Any ideas?

Warren Butler said...

Something that I forgot make clear in my original post was that this text in the /etc/xinetd.d/Xvnc file is all ONE line:

server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd

I have updated the original post with an edit to make this more clear.

Regards

Warren

laguonse said...

Hi Warren, I like your site very much and all the work you put on this, and specially the "Xubuntu Remote Desktop with VNC4Server". I found it very informative and it worked ok directly. But a day after the install, I have found a problem with my Thinkpad 600e Xubuntu desktop. I don't know if it's because of this installation or not, but the Xubuntu menus are gone on the default desktop. I have the Firefox icon in upper left corner on screen, and date with clock and the exit icon in upper right, but no menus near the Firefox icon. Could you or maybe anyone else that have seen this, see any reason for this behaviour? Cheers
Lars, Sweden

Warren Butler said...

Lars,

It sounds like you have just lost the menu applet. Right-click on an empty spot on the panel and select "Add New Item". From the list that opens, go right to bottom and select "XFCE menu". You can just drag-and-drop it to where you would like it on the panel. In your case, the top, left corner. Then right-click on the new item and select "Properties" to change the name and icon.

I don't think it had anything to do with the setup - you may have right-clicked and "Removed" it by mistake.

Let me know if that helps.

Regards

Warren

laguonse said...

Warren,
Many Thanks! It was the menu applet that I seem to have deleted by misstake. The menu is now back again.

Regards

Lars, Sweden

Bryan said...

Ok, easy enough...everything is up and running and I can connect to the VNC server via the command line in Xubuntu. However, I can't figure out how to connect using TightVNC in Windows on another machine on my network. I've tried using the IP address of the Xubuntu machine when TightVNC asks for the VNC Server name, but I haven't had any luck.

PucOuajio said...

You need to append ":1" to the ip address or name, for example:

10.10.100.3:1

or

xubuntupc:1

PucOuajio said...

These instructions worked great for me, but the latest version of vnc4server seems to be broken. I had to downgrade it like so:

$ sudo apt-get install vnc4server/edgy

I found the solution here: https://launchpad.net/ubuntu/feisty/+source/vnc4/+bug/78282

Warren Butler said...

pucouajio,

You're right. I have a more recent post about this here.

Regards

Warren

anotherstuart said...

Running this on xubuntu Edgy works great but note that the instructuions are to not edit the gdm.conf anymore but to chnge gdm.conf-custom instead, otherwise you can lose everything on upgrades.

AlexB said...

Why aren't people just using tightvncserver?? It's right there in the Ubuntu repository. No painstaking configuration necessary, no editing of text files. And yes it does resumable sessions. (I'm stunned that there are actually vncservers out there that don't do something so basic...)

Maneesh said...

Thanks for the thread but I cannot seem to get it to work on my Xubuntu machine. I want to access it from windows using a client like tightVNC. I followed your instructions and i get the following error when I run xvnc4viewer :1 on the local machine

main: unable to connect to host: Connection refused (111)
From the windows machine i simply get "Failed to connect to server" using tight VNC.
I have rebooted the machine and still no joy. I would appreciate any help as i have been "at it" for several weeks now without any luck

Emblem said...

This worked find for me on Edgy, as long as I locked the version to vnc4server/edgy. However, now that I upgraded to Feisty, it stopped working, and I don't know how to downgrade! Help!

S said...

Thanks a lot for the tutorial! I have spend soo many hours getting any vnc to work on ubuntu edgy. It finally worked!

But, what I really want is to access the ubuntu server through a java-enabled browser? I haven't succeded with this yet, does anyone know how to do it? It doesn't work if I simply connect to http://myipadresse:5801 in a browser on a test pc.

Should the server_args in the /etc/xinetd.d/Xvnc file be with -httpd instead of -inetd ?

Again thanks for helping me getting soo far

Cheers

Chris

Tal said...
This post has been removed by the author.
Emblem said...

I solved my problem, and some other Feisty related problems.

Please see the discussion here:

http://ubuntuforums.org/showthread.php?t=414077

I'd like to thank everyone involved in sharing their solutions. I really, really hope the vnc4server bugs are fixed soon. I'm still rather shocked that Feisty was released with a broken package!

anotherstuart said...

I followed all the latest instructions and did the downgrade but I had the login problem (multiple logins for a simgle user) described at http://ubuntuforums.org/showthread.php?t=414077

it's really worth noting this or you get frustrated!

Yclept said...

could you fix this:
-extension XFIXES
(take away the s; extension is singular)

also, to debug:
run Xvnc [server_args], where [server_args] is the exact same as in the xinetd Xvnc file minus the -inetd option
So for example:
server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vnc/passwd -extension XFIXES

lastly, to see the xinetd connections, run:
sudo netstat -tulpena | grep xine

Yclept said...

could you fix this:
-extension XFIXES
(take away the s; extension is singular)

also, to debug:
run Xvnc [server_args], where [server_args] is the exact same as in the xinetd Xvnc file minus the -inetd option
So for example:
server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vnc/passwd -extension XFIXES

lastly, to see the xinetd connections, run:
sudo netstat -tulpena | grep xine

Yclept said...

(i forgot to mention)
and the test would be:
sudo Xvnc :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vnc/passwd -extension XFIXES

Warren Butler said...

@yclept,

Thanks for spotting the typo and the other tips. I have corrected it.

Cheers

Warren

LAMBROS said...

i get this error:

Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

xvnc4viewer: unable to open display ":0.0"
i applied all the setings you discribe...but there is no solution..plz help...

blue said...

hi i followed instructions and everything worked fine but i cant login into gnome, i get the login screen but i cant start session.
I left one gnome session open when had physically access so i want to get that session from vnc, i have ssh access how can i do this ?

running command "w" shows :

00:31:41 up 11:12, 3 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
userXXX :0 - 13:19 ?xdm? 16.35s 0.03s /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserver
userXXX pts/0 :0.0 13:19 11:02 0.05s 0.19s Terminal
userXXX pts/1 189.169.12.145 23:10 0.00s 0.01s 0.02s sshd: userXXX [priv]

Brian said...

Thank you!!!!

You fix for the end of session issue makes me very happy. I had done 2 clean installs trying to get this work. Thanks a million.

d0ze said...

Worked perfectly, thanks a lot!

Swarup said...

First, thank you for the great information.

Second, one question: My original install on this laptop is actually
Ubuntu Hardy. I then added Xubuntu and it runs when I opt to go into it
as a session. My question is, that all the software as well as settings
from Ubuntu have transferred automatically over to Xubuntu-- such as
wireless setup, email, etc etc. So wouldn't the settings of the Remote
Desktop feature have ported over as well? Someone tried to connect with
me, and they didn't see my computer as being available until I rebooted
into an Ubuntu session and then it worked fine.

So does it sound then, like I'll to go ahead and follow the fairly
extensive procedure listed on that blog? Or should there be an easy way
to do it since it is already set up on this computer through Ubuntu?

Also, if you think I need to go through with the manual configuration as
per your blog, then are there any adjustments needed due to this being
Hardy rather than Feisty or Edgy?

Thanks,
Swarup

Swarup said...

Well, I went ahead and followed your instructions above and everything seemed to go perfectly smoothly. And I tried the self-test at the end, and that seemed fine too. I'll try the remote desktop itself in a few minutes with my colleague. But first I need to report that somehow in the process of doing this, now I find that my whole xfce desktop is gone from Xubuntu, along with all the folders and icons etc that I had on the desktop. In its place is the Ubuntu desktop-- even though I am now logged into a Xubuntu session. I'm sure the solution to this must be simple, I but I don't know what it is. Could you tell me?

Swarup said...

I have rebooted into a Xubuntu session, and it has arrived into Xubuntu i.e. the upper panel is in the Xubuntu configuration along with its Applications and Places configuration, but the main desktop is completely with the Ubuntu appearance: it has the brown color with the bird on it, and the visual setup of all the icons and folders on the desktop is that of Ubuntu. Plus, if you right-click on desktop to change the background appearance, it thinks it is Ubuntu-- it is giving me the four options for the Ubuntu background. And yet the Applications drop-down menu is that of Xubuntu. What is going on? Did some step in the above HowTo affect my desktop like this? And how do I fix it?

Swarup said...

1. After all this, the Remote Desktop is still not working. There are three computers in this house, the other two are in Ubuntu and I am (right now) in Xubuntu. And they can't see me. When I change sessions into Ubuntu, then they see me just fine. And I followed all the steps you outlined, and at the end the self-test you gave seemed to give proper information. So why isn't it working.

2. Why is it that when I boot into a Xubuntu session, the desktop looks like it is Ubuntu ever since I followed the HowTo steps you've given? How do I revert it back to look like Xubuntu?

Is anyone there? Hello?

linorics said...

I was wandering. I got this up and running great. But if I want 2 clients to connect to the same screen(two people to remotely work on a file at the same time) it says "The server is already in use". Do you know how I can change this? or got any ideas?

Byte64 said...

thanks for the great step by step tutorial, now i have both x11vnc and vnc4server working.

cheers,
Flavio

kasehDANpercaya said...

Great tutorial.

I managed to get it done for the first time. I restarted my pc and try to reconnect. it gives END OF STREAM error. I checked and found out that i omitted -extension XFIXES.

But now, using nano, i get permission denied to edit the file.

What should i do?

Warren Butler said...

@kasehdanpercaya

That sounds like a permission problem. Have you tried

sudo nano <...rest of command...>

Regards

Warren

kasehDANpercaya said...

Shoot. My bad. I thought i run sudo. Thx for the quick response btw.

Ok, new problem. I tried conntecting from XP machine but keep getting, "protocol version negociated" and it stays at that for a very long time.

This only happen if i connect to seesion 0 (e.g. xubuntu:0). I can log in successfully using new session (e.g. xubunto:1). I'm using tightvnc on XP machine.

zorobabel said...

same as maneesh for me:
i get the following error when I run xvnc4viewer :1 on the local machine
main: unable to connect to host: Connection refused (111)

dlstrife said...

First of all, great article, got me set up easily on the local machine. However, I'm now trying to connect to it from an Ubuntu machine different subnet and I get:

main: unable to connect to host: No route to host (113)

Any Ideas?

fugged said...

thanks for the post! helped out a lot! had some trouble with just getting a grey screen when logging in thru jollyfastvnc so just ssh'd in and did a remote restart and worked perfectly after that.

Fornes said...

Thanks for the guide!

I wrote a guide on how to remote desktop Xubuntu 7.10 using vino. This will let you connect to the current session and resume it afterwards. You should check it out at:

http://layer8problem.blogspot.com/2008/10/howto-remote-desktop-to-xubuntu-710.html

C said...

Xubuntu Ibex 8.10
Follow the instructions above. In gdm.config under [servers] uncomment the line 1=Standard

mrGrumpier said...

drat! I'm now reInstalling Xubuntu 8.10 from CD.

I followed 'faithfully?' thru check-list and ended up in a smelly heap with problems when I try to alter Login Menu settings [I got a new Login Screen] + Connection refused (111) error, tried 1=Server in ..config-custom + problems with local display screen (wrong resolution)!

I would be happy to try again, but is there a new 'definative' guide for Intrepid Ibex??

Faustop said...

The "-extension XFIXES" bug fix did the trick for me .... works great ..... thanks ..

coacharnold@gmail.com

Livin Jean said...

When trying xvnc4viewer:1 , I get this error "Connection reset by peer (104)"

Erik said...

I'm doing something wrong.. looking for some guidance:

I've followed the procedure outlines here.. get "connection refused" by the xvnc4viewer.

When I issue the command test command listed in another comment here (sudo Xvnc :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vnc/passwd -extension XFIXES) I *CAN* successfully connect.

So apparently there is something wrong with my config. I copy/pasted the /etc/inetd.d/Xvnc file verbatim.. carefully observing newlines where I can. Stopped/Started the xinet.d service. Still... the service does not seem to be starting in this way.

What else might I need? Any other suggestions?

Nik said...

Thank you Warren!!! ... After days of various attempts, I found your link to x11vnc "hidden in there" and it worked flawlessly.

Picklegnome said...

For those trying this with Jaunty (and Xubuntu for me specifically):

There are various problems resulting from changes made to Xserver.

Should you get a response along the lines of "Could not init font path element", install the package xfs (X Font Server) with apt-get.

In addition, Xvnc looks in the wrong place for X11 fonts, as they moved post-Dapper. Symlinking /usr/share/X11/fonts to /usr/share/fonts/X11 may solve the problem.

See http://bit.ly/qm6UE
and http://bit.ly/luYHj

parrimin said...

Hi,
I have a strange problem. After doing all of this, i cant reach the xubuntu host from windows vnc viewer. It says unable to connect to host: connection timed out (10060). I can fix this problem going to xubuntu host, and doing a continuous ping to windows host. Then i can reach the server from windows and all running ok. But, i cant understand this behaviour, there is no firewall between lan computers, and there is no iptable rule in the server. Some ideas?

parrimin said...

Hi,
I have a strange problem. After doing all of this, i cant reach the xubuntu host from windows vnc viewer. It says unable to connect to host: connection timed out (10060). I can fix this problem going to xubuntu host, and doing a continuous ping to windows host. Then i can reach the server from windows and all running ok. But, i cant understand this behaviour, there is no firewall between lan computers, and there is no iptable rule in the server. Some ideas?