Go Back   Ubuntu Forums > Ubuntu Release Assistance > Other Support Categories > Faqs, Howto, Tips & Tricks

Faqs, Howto, Tips & Tricks The place to find General, KDE, and Gnome Customization Tips & Tricks.

Tags: , , , , ,

HOWTO: Set up VNC server with resumable sessions

Reply
Thread Tools Search this Thread Display Modes
  #1  
Old January 27th, 2006
Tichondrius Tichondrius is offline
A Carafe of Ubuntu
 
Join Date: Jan 2005
Beans: 195
HOWTO: Set up VNC server with resumable sessions

So here's the complete list of steps that are required to set the VNC server that any user can login into and start a session. It is also persistent, meanning that even if you disconnect the VNC client your X session will not end (unless you explicitly log out) and you can reconnect to the same session again. The VNC server uses a separate display (:1) than your regular X server, which works with your physical display (:0). So two sessions can be active at the same time (one person sitting at the physical display and another remotely connecting using VNC).

1. Enable XDMCP
System->Administration->Login Screen Setup
Tab Security->Enable XDMCP
Tab XDMCP--> You can disable "Honor Indirect Requests"

Note: Before doing the next step, you need to make sure the extra repositories (e.g. universe) are enabled:
http://easylinux.info/wiki/Ubuntu#Ho...a_repositories

2. Install required packages (vncserver and xinetd)

Code:
sudo apt-get install vnc4server xinetd
Note to AMD64 users: The current version of vnc4server in the repositories has a bug, so you need to download and install the fixed vnc4 packages as shown below:

Code:
wget http://qt1.iq.usp.br/download/vnc4server_4.0-7.3_amd64.deb wget http://qt1.iq.usp.br/download/xvnc4viewer_4.0-7.3_amd64.deb sudo dpkg -i vnc4server_4.0-7.3_amd64.deb sudo dpkg -i xvnc4viewer_4.0-7.3_amd64.deb

3. Set the VNC passwd
Code:
sudo vncpasswd /root/.vncpasswd
4. Add vnc service to xinetd:
Code:
sudo gedit /etc/xinetd.d/Xvnc
Enter this into the new file:

Code:
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/X11/fonts/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd port = 5901 }
5. Restart xinetd (usually there is no need to reboot, but occasionally it might be required)

Code:
sudo /etc/init.d/xinetd stop sudo killall Xvnc sudo /etc/init.d/xinetd start
6. That's it! To test that this is working first try to connect from the same machine (the machine we just set up the VNC server on):

Code:
vncviewer localhost:1
You should be prompted for the VNC password, and then see the GDM login screen where you can login and start a new X session. If that works, you can now go ahead and try to connect from remote machine using your favorite VNC client (remember to first close the local vncviewer we started above). Remember to use the VNC server machine's domain name or IP address, followed by :1 (e.g. 192.168.0.100:1). If connecting locally as shown above works, but connecting remotely fails, then this means you have a problem with a firewall which is blocking some ports. See the notes below about how to deal with that.

Note about ports: The VNC server set up as shown uses TCP port 5901. If you are using firewall software (e.g. firestarter) on that machine, you need to allow incoming connections on this port. If you are using a router which assigns your machine a private address (e.g. 192.168.0.100) which is not accessible from the internet, then you need to forward TCP port 5901 from the router to this machine.

Note about security: This setup allows any user to start an X-session remotely by logging in using his regular password (after starting the VNC connection using the VNC password), so if the user disconnects without logging out, any other user which knows the VNC password can connect afterwards and resume the same session that the first user started. So if you do not want to log out before disconnecting, it's advisable to at least lock your VNC X-session screen. Also note that while a remote user is connected thru VNC, no other connection will be accepted. An idle VNC client will be disconnected after one hour, but this can be changed by using the "-IdleTimeout" option in the server_args line in /etc/xinetd.d/Xvnc. For example, you can add "-IdleTimeout 300" to change it to 5 minutes.

Last edited by Tichondrius : February 20th, 2006 at 02:44 PM.
Reply With Quote
Sponsored Links
  #2  
Old January 27th, 2006
arnieboy's Avatar
arnieboy arnieboy is offline
Tall Cafè Ubuntu
 
Join Date: Mar 2005
Location: Pennsylvania, USA
Beans: 3,164
Ubuntu 6.06 User
Send a message via AIM to arnieboy Send a message via Yahoo to arnieboy
Re: HOWTO: Set up VNC server with resumable sessions

u are all set.. the other howto on VNC to GDM stands defunct from now on.
__________________
Automatix: Just works!
Reply With Quote
  #3  
Old January 28th, 2006
mssm mssm is offline
5 Cups of Ubuntu
 
Join Date: Apr 2005
Beans: 54
Re: HOWTO: Set up VNC server with resumable sessions

Tichondrius, Thanks a lot for the update. As I understand, I should remove the old /etc/xinted.conf file which the old how-to told us to create, right? I also found that XDMCP uses port 177 with UDP protocol. So this port should be taken in the router's config.(i.e. firewall and port forwarding)?

Can it be used to let a specific user login via vnc?

Update : This is the output I got after I borught back /etc/xinited.conf to its original form and then following Tichondrius how-to. I have an AMD chipset, so I installed vncserver(instead of vnc4server). Moreover, I have opened port 177 in my router's firewall with UDP protocol and forwarded this port to my machine's internal LAN IP address. Also port 5901 is open in my firewall and forwarded to my laptop's LAN IP.

From the old how-to I still have this line in /etc/services

vnc1024 5901/tcp # VNC & GDM

Should I remove it? I am confused. I got this response by issuing the following command :

$ vncviewer localhost:1
VNC viewer version 3.3.7 - built Sep 27 2005 11:12:00
Copyright (C) 2002-2003 RealVNC Ltd.
Copyright (C) 1994-2000 AT&T Laboratories Cambridge.
See http://www.realvnc.com for information on VNC.
ReadFromRFBServer: rdr::SystemException: read: Connection reset by peer (104)

Last edited by mssm : January 28th, 2006 at 04:44 AM.
Reply With Quote
  #4  
Old January 28th, 2006
Tichondrius Tichondrius is offline
A Carafe of Ubuntu
 
Join Date: Jan 2005
Beans: 195
Re: HOWTO: Set up VNC server with resumable sessions

You only need to do the steps in this howto. All other steps mentioned in the old howto (like editing /etc/xinetd.conf or /etc/services) are not required and may in fact interfere with this setup.

You need to have the original file /etc/xinetd.conf (from the xinetd package) which looks like this:

Code:
# Simple configuration file for xinetd # # Some defaults, and include /etc/xinetd.d/ defaults { } includedir /etc/xinetd.d
Notice how it instructs xinetd to load all the file in directory /etc/xinetd.d which is were we put the new Xvnc service configuration file. So restore the original /etc/xientd.conf if you made a backup copy, or just edit it to look like shown above.

After you've restarted the xinetd as shown in the step 5, you can check that xinetd is listening on port 5901 by doing this:

Code:
sudo netstat -tap | grep xinetd
And you should see a line like this: (your process ID doesn't have to be the same as mine 10932)

tcp 0 0 *:5901 *:* LISTEN 10932/xinetd

Now you can try to connect with the local VNC client

Code:
vncviewer localhost:1
Let me know if this works.

Last edited by Tichondrius : January 28th, 2006 at 07:09 AM.
Reply With Quote
  #5  
Old January 28th, 2006
mssm mssm is offline
5 Cups of Ubuntu
 
Join Date: Apr 2005
Beans: 54
Re: HOWTO: Set up VNC server with resumable sessions

Hi,

I have followed your instruction in toto but this command yields nothing :
sudo netstat -tap | grep xinetd

It just stays there without giving any output. Also I think the last line of step 5 of your how-to should be sudo /etc/init.d/xinetd start instead of sudo /etc/init.d/xinetd/start. I have also commented the line I entered in /etc/services following the old how-to.

I am running kubuntu though the display manager for login is gdm. Should I reboot then? Also I installed vncserver and not vnc4server since I have AMD64 chipset. Should I install vnc4server instead of vncserver?

Last edited by mssm : January 28th, 2006 at 08:04 AM.
Reply With Quote
Sponsored Links
  #6  
Old January 28th, 2006
Tichondrius Tichondrius is offline
A Carafe of Ubuntu
 
Join Date: Jan 2005
Beans: 195
Re: HOWTO: Set up VNC server with resumable sessions

Quote:
Originally Posted by mssm
Hi,

I have followed your instruction in toto but this command yields nothing :
sudo netstat -tap | grep xinetd

It just stays there without giving any output. Also I think the last line of step 5 of your how-to should be sudo /etc/init.d/xinetd start instead of sudo /etc/init.d/xinetd/start. I have also commented the line I entered in /etc/services following the old how-to.

I am running kubuntu though the display manager for login is gdm. Should I reboot then? Also I installed vncserver and not vnc4server since I have AMD64 chipset. Should I install vnc4server instead of vncserver?
Yes, please reboot. And then check again if xinetd is listening on port 5901 using the command

Code:
sudo netstat -tap | grep xinetd
as I explained previously. If it still doesn't show anything, you should check the system log to see why xinetd didn't read the Xvnc service file.

Code:
grep xinetd /var/log/syslog
And you should see a few lines showing xinetd activity. Look for a line mentioning xvnc, it should look similar to this:

Quote:
Jan 27 03:42:32 localhost xinetd[10932]: Reading included configuration file: /etc/xinetd.d/Xvnc [file=/etc/xinetd.conf] [line=11]
Look for any error messages, or if it loaded successfully you should see another line which looks like this:

Quote:
Jan 27 03:42:32 localhost xinetd[10932]: Started working: 1 available service
btw, you are right about the spelling mistake in step 5, I corrected it. Also I understand you are using kubuntu on amd64, and if vnc4server package is not available for amd64, then vncserver (which is version 3.x) should be OK.

Let me know if this works.

Last edited by Tichondrius : January 28th, 2006 at 08:39 AM.
Reply With Quote
  #7  
Old January 28th, 2006
mssm mssm is offline
5 Cups of Ubuntu
 
Join Date: Apr 2005
Beans: 54
Re: HOWTO: Set up VNC server with resumable sessions

Thanks Tichondrius. I rebooted and this time I got an answer from both the commands :

$ sudo netstat -tap | grep xinetd
tcp 0 0 *:5901 *:* LISTEN 8397/xinetd

$ grep xinetd /var/log/syslog
Jan 28 15:05:06 localhost xinetd[8397]: Reading included configuration file: /etc/xinetd.d/Xvnc [file=/etc/xinetd.conf] [line=11]
Jan 28 15:05:06 localhost xinetd[8397]: Reading included configuration file: /etc/xinetd.d/chargen [file=/etc/xinetd.d/chargen] [line=12]
Jan 28 15:05:06 localhost xinetd[8397]: Reading included configuration file: /etc/xinetd.d/daytime [file=/etc/xinetd.d/daytime] [line=28]
Jan 28 15:05:06 localhost xinetd[8397]: Reading included configuration file: /etc/xinetd.d/echo [file=/etc/xinetd.d/echo] [line=26]
Jan 28 15:05:06 localhost xinetd[8397]: Reading included configuration file: /etc/xinetd.d/time [file=/etc/xinetd.d/time] [line=26]
Jan 28 15:05:06 localhost xinetd[8397]: removing chargen
Jan 28 15:05:06 localhost xinetd[8397]: removing chargen
Jan 28 15:05:06 localhost xinetd[8397]: removing daytime
Jan 28 15:05:06 localhost xinetd[8397]: removing daytime
Jan 28 15:05:06 localhost xinetd[8397]: removing echo
Jan 28 15:05:06 localhost xinetd[8397]: removing echo
Jan 28 15:05:06 localhost xinetd[8397]: removing time
Jan 28 15:05:06 localhost xinetd[8397]: removing time
Jan 28 15:05:06 localhost xinetd[8397]: Started working: 1 available service

Then
$ vncviwer localhost:1
gives me the same msg. as before. After this again I issued :
$ grep xinetd /var/log/syslog
which yielded
Deactivating service Xvnc due to excessive incoming connections. Restarting in 10 seconds.
Jan 28 15:08:18 localhost xinetd[8397]: Activating service Xvnc

But there were many error msgs.

What exactly should I get after issuing vncviewer localhost:1?

Last edited by mssm : January 28th, 2006 at 09:20 AM.
Reply With Quote
  #8  
Old January 28th, 2006
kacheng kacheng is offline
5 Cups of Ubuntu
 
Join Date: Dec 2005
Beans: 54
Re: HOWTO: Set up VNC server with resumable sessions

I also get the following when issuing:

# vncviewer localhost:1
VNC viewer version 3.3.7 - built Sep 27 2005 12:10:30
Copyright (C) 2002-2003 RealVNC Ltd.
Copyright (C) 1994-2000 AT&T Laboratories Cambridge.
See http://www.realvnc.com for information on VNC.
ReadFromRFBServer: rdr::SystemException: read: Connection reset by peer (104)


I am also running AMD64, with vncserver (not vnc4server) installed.
Reply With Quote
  #9  
Old January 28th, 2006
kacheng kacheng is offline
5 Cups of Ubuntu
 
Join Date: Dec 2005
Beans: 54
Re: HOWTO: Set up VNC server with resumable sessions

I also get as mssm does:

# grep xinetd /var/log/syslog
Jan 28 08:29:56 localhost xinetd[13968]: warning: can't get client address: Transport endpoint is not connected
:
:
:
Jan 28 08:29:57 localhost xinetd[14180]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14181]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14182]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14183]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14184]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14185]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14186]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[14187]: warning: can't get client address: Transport endpoint is not connected
Jan 28 08:29:57 localhost xinetd[10673]: Deactivating service Xvnc due to excessive incoming connections. Restarting in 10 seconds.
Jan 28 08:30:07 localhost xinetd[10673]: Activating service Xvnc


What does this mean?

Last edited by kacheng : January 28th, 2006 at 09:44 AM.
Reply With Quote
  #10  
Old January 28th, 2006
kacheng kacheng is offline
5 Cups of Ubuntu
 
Join Date: Dec 2005
Beans: 54
Re: HOWTO: Set up VNC server with resumable sessions

I was just going through the HOWTO again and noticed that the Xvnc service doesn't seem to start:


$ sudo /etc/init.d/xinetd stop
Stopping internet superserver: xinetd.
$ sudo killall Xvnc
Xvnc: no process killed
$ sudo /etc/init.d/xinetd start
Starting internet superserver: xinetd.
$ sudo /etc/init.d/xinetd stop
Stopping internet superserver: xinetd.
$ sudo killall Xvnc
Xvnc: no process killed
$ sudo /etc/init.d/xinetd start
Starting internet superserver: xinetd.


I'll reboot and try again.
Reply With Quote
Sponsored Links
Reply



Forum Jump


All times are GMT -4. The time now is 11:29 AM.


vBulletin Version 3.6.3. ©2000 - 2006, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project.

Warning: include(../../../google.php): Failed to open stream: No such file or directory in /web/westerfunk/archives/technology/Ubuntu - VNC Resumable Sessions/index.php on line 3118

Warning: include(): Failed opening '../../../google.php' for inclusion (include_path='.:/usr/share/php') in /web/westerfunk/archives/technology/Ubuntu - VNC Resumable Sessions/index.php on line 3118