Start a VNC Server on Ubuntu on Boot

Ubuntu makes many things easy. For example, with Gnome, it's very simple to set up remote access to your desktop with the included Vino application. The only problem is that to get the VNC server running, you have to be logged in! Luckily, it's not too difficult to create a script which starts up the server as soon as your system boots. This is especially handy if you are running a headless server, or are using the primary display for other purposes. In this case, my server runs MythTV on the normal X server connected to my TV, but starts up Azureus and K3B in a VNC session so I can access them without bothering those watching TV.

To set it up, follow these steps:

  1. First, install the TightVNC server. This VNC server has excellent compatibility with clients, and provides reasonable compression for slow networks. It can be installed with Synaptic, or with sudo aptitude install tightvncserver.
  2. Set up the VNC server for the user you wish to log in as. When you run "vncserver" for the first time, it will ask you to set a password. VNC authentication is not the strongest encryption available, so be sure to firewall your server from all but trusted machines. Better yet, deny direct access to VNC and only allow SSH tunnelled or VPN connections. To launch programs or a session when your VNC session starts, modify ~/.vnc/xstartup. Here is my copy of xstartup: it runs an icewm session, Azureus, and K3B. For Gnome, try running "gnome-session", and for KDE, try "startkde".
    #!/bin/sh

    xrdb $HOME/.Xresources
    xsetroot -solid black
    /opt/azureus/azureus &
    k3b &
    icewm-session &

  3. Copy the following into /etc/init.d/vncserver. The easiest way to do it is to copy it to your clipboard, run sudo -i && cat > /etc/init.d/vncserver && exit in a terminal, paste it in, and type CTRL-D. Be sure to change the USER variable to whatever user you want the VNC server to run under.
    #!/bin/sh -e
    ### BEGIN INIT INFO
    # Provides:          vncserver
    # Required-Start:    networking
    # Default-Start:     3 4 5
    # Default-Stop:      0 6
    ### END INIT INFO

    PATH="$PATH:/usr/X11R6/bin/"

    # The Username:Group that will run VNC
    export USER="mythtv"
    #${RUNAS}

    # The display that VNC will use
    DISPLAY="1"

    # Color depth (between 8 and 32)
    DEPTH="16"

    # The Desktop geometry to use.
    #GEOMETRY="<WIDTH>x<HEIGHT>"
    #GEOMETRY="800x600"
    GEOMETRY="1024x768"
    #GEOMETRY="1280x1024"

    # The name that the VNC Desktop will have.
    NAME="my-vnc-server"

    OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

    . /lib/lsb/init-functions

    case "$1" in
    start)
    log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
    su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
    ;;

    stop)
    log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
    su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
    ;;

    restart)
    $0 stop
    $0 start
    ;;
    esac

    exit 0

  4. Make the script executable with sudo chmod +x /etc/init.d/vncserver.
  5. Then, run sudo update-rc.d vncserver defaults. This adds the appropriate symlinks to the vncserver script so that it is sent the start and stop commands at the appropriate time. Update: jpb writes that you may need to use sudo update-rc.d vncserver 99 instead if the job is running too early in the boot process.
  6. To start the server without rebooting, run sudo /etc/init.d/vncserver start
  7. Finally, connect to your server with a VNC client on port 590X, where X is the value of "DISPLAY" in the vncserver script. On OS X, I like to use Chicken of the VNC. On Windows and Linux, the TightVNC client works nicely.

Of course, this script should work as expected on any Debian-based distribution. If you have problems with performance, try lowering the screen resolution. 800x600 is much faster than 1024x768 over slow connections.

Comments

Thank you for this good

Thank you for this good tutorial.
But the configuring of Runlevels is done with:

update-rc.d vncserver defaults

Good catch! I've updated the

Good catch! I've updated the article.

nice

only want to say well done article

Finally!

Don't know why it was so hard to find *tight* vnc server + ubuntu + start before logging in... so many permutations of useless info before I came here :)

"Command not found"?

I'm trying to run the script and I can't get it to work properly. I've been running it and all I get is "sudo: /etc/init.d/vncserver: command not found"

type sudo nano

type sudo nano /etc/init.d/vncserver

Set executable!

I figured it out. You should amend your script to set the execute bit sudo chmod +c /etc/init.d/vnccserver

Updated the article

Thanks for the feedback - I've updated the article to note setting the execute bit.

One step closer

It's working now, however on reboot It does not launch the commands in ~/.vnc/xstartup, the curious thing is that if I run it manually, it works fine.

Perhaps you need to set the

Perhaps you need to set the execute bit on your xstartup file as well? Though it should be created automatically when you first run the server.

Can't log in after connection.

I completed the installation procedure and everything seems to be OK. But after I made connection, using a tightvnc client, I get a blank screen. At that moment there is no user logged in at the host yet. When I start the vncserver at the host after there is logged in a user there is no problem. Can anybody tell me what is wrong.

xstartup?

It sounds like it might be caused by the contents of your xstartup file. When the VNC server starts, there should be whatever processes you asked the VNC server to start. Try running:

ps auxww | grep <vncserver-user>

to see if processes are running as expected or not.

great write-up, I tried to do

great write-up, I tried to do this in 8.04 LTS and got the same issue of just a blank grey screen, no login

myusername@ubuntu:~$ ps auxww | grep myusername
myusername 6011 0.0 0.1 7428 5168 ? S 09:59 0:00 Xtightvnc :1 -de/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 120000 -rfbauth /home/myusername1R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/foni/,/usr/X11R6/lib/X11/fonts/100dpi/,/usr/share/fonts/X11/misc/,/usr/share/fonts/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb
myusername 6032 0.2 0.6 79828 21324 ? S 09:59 0:00 x-terminal-emulmy-vnc-server Desktop
myusername 6033 0.1 0.3 20120 11544 ? S 09:59 0:00 x-window-manage
myusername 6130 0.1 0.1 6984 4064 ? S 09:59 0:00 /usr/lib/libgco
myusername 6528 0.0 0.0 3008 600 ? S 09:59 0:00 dbus-launch --ab427 --binary-syntax --close-stderr
myusername 6529 0.0 0.0 2568 868 ? Ss 09:59 0:00 /usr/bin/dbus-dress 7 --session
myusername 6534 0.0 0.0 2796 752 ? S 09:59 0:00 gnome-pty-helpe
myusername 6535 0.0 0.1 5708 3120 pts/0 Ss+ 09:59 0:00 /bin/bash
root 6552 0.0 0.1 11384 3840 ? Ss 10:01 0:00 sshd: myusername [p
myusername 6554 0.0 0.0 11384 1872 ? R 10:01 0:00 sshd: myusername@pt
myusername 6555 0.0 0.1 5720 3152 pts/1 Ss 10:01 0:00 -bash
myusername 6578 0.0 0.0 2644 1012 pts/1 R+ 10:04 0:00 ps auxww
myusername 6579 0.0 0.0 3008 776 pts/1 S+ 10:04 0:00 grep myusername

anything look strange?

Definitely sounds like your

Definitely sounds like your xstartup is broken somehow. There should be processes from whatever desktop environment or programs you're trying to run. You can start with simple steps by running just /usr/bin/xterm, or try installing icewm and just use the xstartup file I have in the article.

Fixed issue with gray screen at startup

I too was having an issue where the VNC server was getting started, but I saw only a gray screen when I connected to it from a remote client. After some investigation, I realized the the VNC server was being started too early in the boot process, perhaps before the X windows subsystem had been completely initialized. I was able to solve this problem by removing the vncserver script from the startup sequence using:

sudo update-rc.d -f vncserver remove

and then adding it back using:

sudo update-rc.d vncserver defaults 99

The value of "99" indicates that this script should be run later in the startup process. Other values may work for you, but the value that was being used in my case by default was 20, and that caused it to be run too early.

Andrew - You may want to add a note about this in the original writeup. And thanks, by the way, for writing this up - it got me 95% of the way there.

This is likely related to the

This is likely related to the fact that in the time since I wrote the article for Ubuntu 8.04, there's a lot of work that's gone into making startup tasks run in parallel. Thanks for the tip, I've updated the article.

Thank you!

Thank you for this! I've been looking for a seemless way to start X and VNC all in one. Maybe you should add a part about changing the username from "mythtv" to something else, but I guess everyone can figure it out. Tested working 100% as the guide said it on Ubuntu 8.10 x86_64.

Added note about changing the user

Glad to hear that the steps still work as expected on 8.10, as I haven't upgraded from 8.04 yet. I've updated the article with a note about changing the USER variable to something valid.

/etc/init.d/vncserver "No such file"

It's very strange. Followed guide, but got stuck here:

sudo cat /etc/init.d/vncserver works. However:
sudo /etc/init.d/vncserver start results in :
sudo: unable to execute /etc/init.d/vncserver: No such file or directory

any thoughts?

Finally Working! Thank god (and andrew)

re-did it from scratch. this by typing in on the terminal (before i did cut&paste from windows using vnc). I think this has something to do with the involvement of Windows somewhere in the process.
Anyway - after so 3 days of frustration it finally works!
Thank you!

Glad to hear you got it

Glad to hear you got it working. My guess is that Windows line endings got placed in the file somehow. I've had better success with such things by using SSH + putty, if you're stuck on Windows.

thanks

have been trying (unsuccessfully) to get this to work exactly as you did for a long time — thanks for the vncserver init.d script

awesome (;

Everytime I use the script, I got a prompt asking for password

if I input the password, the script runs well.

But when this script automatically run on boot, I do not get a chance for inputting password.
So the vncserver will not get started.

Can you tell me how can I prevent the password being asked when using the script?
Thank you in advance.

Do you have a password set

Do you have a password set for the user? You can change it with vncpasswd, and check that it exists by looking in ~/.vnc/passwd. vncserver should only ask for a password if one doesn't exist.

Or, is your startup script running the vnc server as the same user that you set up? Perhaps it's trying to run as root or some other user.

xstartup not being launched

I too am having a problem with xstartup not being launched. Not sure what to do.

Has Anyone Solved the xstartup issue

Whats the problem with the xstartup file not being read/executed on startup? When I start vncserver manually it works just fine, but when I log in with just the startup scripts the server is started, but gnome isn't.

If you DO get an X-server

If you DO get an X-server (gray with the old style mous-pointer) you might want to adding the following (for gnome) to the top of your xstartup file:

unset SESSION_MANAGER
exec sh /etc/X11/xinit/xinitrc

However, I (as well as others) am experiencing theme-switching. The theme-chooser will very shortly change the theme, but when I stop using the chooser itself it refers back to the default icon/theme appearance. Anyone got an idea/link?

How could I modify this

How could I modify this script for five users each running there own vnc window?

Is this possible?

For five users, it's probably

For five users, it's probably easiest just to copy the init.d script for each user, and modify the USER variable. Or, for a little more robustness, turn that variable into a list of users sourced from a configuration file, and loop over each user for the start and stop actions.

So copy the init.d script

So copy the init.d script just change the User,display and script name for each user.

I cannot get this to work on

I cannot get this to work on ubuntu 8.10 it works fine on 9.04.

First of all the 8.10 asked for the required-stop section from the init info so I created that section.

# Required-Stop: networking

I can start manually by "sudo /etc/init.d/vncserver start" but will not start automatically from boot.

Can anyone help?

That's rather strange. I'm

That's rather strange. I'm currently running 9.04, and I'm pretty sure that 8.10 loaded the session fine (though I only had 8.10 installed for a few hours). You're sure you ran sudo update-rc.d vncserver defaults? There should be symlinks in the following locations:

/etc/rc0.d/K20vncserver
/etc/rc1.d/K20vncserver
/etc/rc2.d/S20vncserver
/etc/rc3.d/S20vncserver
/etc/rc4.d/S20vncserver
/etc/rc5.d/S20vncserver
/etc/rc6.d/K20vncserver

Yes on 8.10 I only have

Yes on 8.10 I only have symlinks in these locations

/etc/rc0.d/K20vncserver1 -> ../init.d/vncserver
/etc/rc1.d/K20vncserver1 -> ../init.d/vncserver
/etc/rc6.d/K20vncserver1 -> ../init.d/vncserver
/etc/rcS.d/S20vncserver1 -> ../init.d/vncserver

Well that's the problem.

Well that's the problem. Either create the symlinks manually, or re-run the update-rc.d command to create them.

/bin/sh: Illegal option -

Thanks for this write-up. I have followed all the steps but cannot get "sudo /etc/init.d/vncserver start" to work. It returns: "/bin/sh: Illegal option -". I am running Ubuntu 9.10. I have created the script twice but it does not solve the problem. Even if I reduce the script to e.g. only the first 5 lines, it returns the same error.
Manually (via command "/usr/bin/vncserver -name my-vnc-server -depth 24 -geometry 1280x1024 :1") I get it to work without problems and can connect. Any idea?
Thanks.

I wonder if 9.10's /bin/sh

I wonder if 9.10's /bin/sh has changed; perhaps it doesn't like the -e parameter. Try removing it, or changing /bin/sh to /bin/bash or /bin/dash?

I have tried the

I have tried the following:
1) Removing the -e parameter and "sudo /etc/init.d/vncserver start" returns: "/bin/sh: Can't open".
2) Changing to "/bin/bash -e" returns "/bin/bash: Illegal option -"
3) Changing to "/bin/bash" returns ": file or folder does not exist"
4) Same for "/etc/dash -e" and "/etc/dash"

The only thing I can think of is that directory "/usr/X11R6/bin/" does not exist on my machine, nor does folder "X11R6" (in another location). I am still open for other ideas ;-)

Same Problem

I am having the same problem it sounds like. I am running 10.04 and this is what I get when I run the vncserver start command:

sudo /etc/init.d/vncserver start
* Starting vncserver for user 'shon' on localhost:1...
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file

Any suggestions?

Does the file have Windows

Does the file have Windows line endings instead of Unix line endings? From those errors it seems like the script file is corrupted somehow.

Thanks!

I was upset that it was so hard to run a headless machine with Ubuntu 9.10, but this procedure worked great for me!

Works! But...

This works perfectly, except that once Im into the desktop, it seems to think I have a German or french keyboard, instead of a british. any way to solve? under keybord, it says i have a british one, but it's not typing as one

wrong keyboard characters too...

I'v got the same problem like Dave...

How do I connect to display :0

Excellent article. I did some small modification for my user name and screen resolution and everything is still working. I have one issue. how do I VNC into display "0" instead of "1"? The reason is to access programs which are already running on display "0". Display "0" has already been assigned to my session that I logged in on the server.
If I leave Thunderbird mail running on the server on display "0", I cannot see it on display "1" when I am accessing the server from remote desktop. I usually leave some programs running and just lock the screen.

Either use hostname:1, where

Either use hostname:1, where 1 is the display number, or hostname:5901, where 5901 is the port. By default, :1 automatically maps to 5901, and increments up.

Where to use hostname:1 ? on

Where to use hostname:1 ?
on client or on server as an option while starting vncserver hostname:1

That's the syntax for

That's the syntax for connecting from a client. For example, when I want to connect from TightVNC to VNC running on the server blizzard on display 1, I would put blizzard:1 in the hostname field.

No /etc/init.d/vncserver file or directory...

This looks exactly like what I am looking for. I need to run a headless machine that I can setup 2-3 remote users to login with their own accounts. So I need to start VNC on a restart and not have to log in as each one and start the service manually.

I am trying this but when I run sudo cat> /etc/init.d/vncserver I get the error "cat: /etc/init.d/vncserver: No such file or directory"

Any ideas on what this could be? I am running Ubuntu 10.04.
Also is there a way to modify this to allow different VNC servers to run for different users on different ports?

Thanks for your input!

You should be able to modify

You should be able to modify the script easily, either by having one script for each user, or adding in some additional code to handle your case with a few loops.

When you do sudo <cmd> > /path/to/file, only the command, and not the shell redirection, is run as root. Try doing sudo -i and then the cat, or just do sudo vim and paste in the code.

Edit: Which makes me wonder why it worked when I first wrote the article! I've updated the article to use a functional method.

Just what I needed

Thanks a lot for this init script! It's just what I needed for my dedicated OpenVZ torrenting container. You've allowed me to put off learning more about bash scripting a little longer.

Tightvnc Server crash

Hi!

I installed VNC as in this tutorial described! Thank you very much it works great!

As desktop environment I installed the package "gnome-core". It works fine until a certain moment when the connection is used over serveral days (also using KDE programs). Then suddenly the server crashes and I have to delete some temporary files from /tmp: ".X101-lock" and ".X11-unix". then the server has to be restarted. Is this a known problem ? Has anyone got an idea how to fix this? Does the vnc process have too little memory assigned?

Thank you very much for any help!

Accidently gave vnc user root priveleges

Fresh install of Ubuntu 10.04 - first thing I did was install tightvncserver as above (great piece, thank you).

Logging in with TightVNC I was surprised to see the user was "root". Scared the crap out of me.

Best guess is the first time I ran the script (that creates the .vnc directory and password file) I must have typed "sudo".

Reasoning: ownership of ~/.vnc and ~/.Xauthority was root:root.

Fixed it by changing the permissions of ~/.vnc and ~/.vnc/passwd, deleting the .Xauthority files, deleting the ~/.vnc/server:1.log and server:1.pid files; stopped the service, then reran the startup script.

Still confused on the difference between running "/etc/init.d/vncserver start" and simply "vncserver".

Thank you.

Thanks

Worked like a charm on Lucid Lynx (Ubuntu 10.04)

Thanks!

Everything mentioned here

Everything mentioned here also works on Ubuntu 10.04.
Knowing little about bash scripting I got my set up with multiple VNC servers for multiple users working by using
the last script on the page here .
with just one small change. Changed /bin/sh to /bin/bash. This is because in ubuntu the default shell is not bash
thus requiring you to be expllicit.

Edit: Broken link fixed.

Thank You

Worked like a charm. Thank you very much it works great!

Black Screen after reboot for VNC connection

I have set this up and after rebooting I try to connection via VNC and end up with a black screen... :|

Any thoughts?

My guess would be that the

My guess would be that the VNC session is started, but no programs are actually running. If you know the display number (often :10) you can try manually running a program and it should show up in that session:

$ export DISPLAY=:10
$ xterm

Also consider checking with ps auxww to see if your expected programs are running.

Don't bother

I wanted an easy solution to remote into my ubuntu 10.04 box on the lan before any login.

Well, if you want to do this and not have to think about it do the following:

Step 1). Go to the following site depending on your bit version of ubuntu:
For the server (computer you want to connect to) you need client, node, and server installed but for the client you only need the client.

For 32 Bit: http://www.nomachine.com/download-package.php?Prod_Id=2249
For 64 Bit: http://www.nomachine.com/download-package.php?Prod_Id=2247

So for the server install the client, then the node, and then server deb; on ubuntu this should be just a download and it will take it from there.

Step 2). Test locally via the menu [Applications][Other][NX Client]
Provide any session name, your user name, and pasword - I believe you can also connect to an existing session (have not tried this yet) , Note: you may get a prompt but it will ask if you wish to connect anyway and say yet - this is just a test.

Step 3). Close everything up and reboot and go to another computer on the LAN or with access to the IP.

Step 4). Install the NX client from the appropriate links above.

Step 5). Start the client using the same steps above and enter the same information but change the IP from 127.0.0.1 to what ever IP you have.

For me this is all I did and I have 10.04 on both. It works no problem.

Thanks NX!

Long live Ubuntu!.

X-Authorisation File

I have setup VNC Server as per the instructions above. I have not been able to run the script file at startup and I am using cron to start/stop. The VNC client is working now. However a number of admin tasks do not work as the "X-Authorisation" file cannot be found. Can this path be added to any of the setup files or is there a simple solution?

Crashing

https://bugs.launchpad.net/ubuntu/+bug/344264

Xtightvnc version 1.3.9 will crash when handling some 64bit values. 1.3.9 is the version in the Ubuntu repositories as of 1/14/2010.

This is supposedly fixed in 1.3.10, however installing that requires downloading/compiling source.

Unable to get it started

jdube@Falken:/usr/bin$ sudo /etc/init.d/vncserver start
* Starting vncserver for user 'jdube' on localhost:1...
Couldn't start Xtightvnc; trying default font path.
Please set correct fontPath in the vncserver script.
Couldn't start Xtightvnc process.

Unrecognized option: --
use: X [:] [option]

suggestions?

Good grief!

This torturous, scatter-shot configuration drama - not uncommon, it seems - is not a recommendation.

Too right!

Let's see… in OS X all I have to do is select the server I want from the Shared area of the Finder window (for local-network systems), click the 'Share Screen' button and enter my login credentials. Works first time, every time in my experience.

This kind of arcane masochism is why I left Linux as a day-to-day desktop after 10+ years of use and evangelism. If your time and sanity are worth anything at all to you, you start looking for ways to make the tools you use to do your work get out of the way as much as possible so you can accomplish the mission you set out to. Digging coal to fire a furnace on which you forge blades with which to shave your yak is the historically pandemic Linux experience, and that's why proportionally fewer people are using it as a desktop system now than 5 years ago, and fewer still will be in 5 years' time unless Ubuntu and friends get out of their navels and start innovating again. When anyone asks me about putting a Linux desktop on an existing PC, I recommend openSUSE, Fedora and Mint. It's been two years since anybody asked me about Ubuntu… and getting people off Windows was my bread-and-butter business until very recently.

Get Grey screen with x only

I followed the article on Ubunto 10.04 LTS. Went fine but when I connect using RealVNC viewer to my device I get a grey screen with an x that moves with the mouse. Anu ideas what causes this?

# Default-Start: S ? (S as in Sam?)

Shouldn't it be 5 as in, well, five?

I looked into this, and while

I looked into this, and while "S" isn't really wrong, it's not the best either. "S" means to run the script any time before switching run levels. What we really want is for it to run after base services have been started. I've changed the script to default start at levels 3 4 5, which should work fine. Thanks!

Deserves an MVP: Most Valuable Post!

Even though your original post is nearly three years old, it's still the clearest - and most successful - description of how to configure a vncserver anywhere on the net. And the various problem descriptions, along with the responses and advice on how to correct, are still enormously useful.

Of course, I might just feel this way because I just spent the whole bleeding day trying to get TightVNC on Ubuntu and Windows to cooperate with one another. It was this post that got me through it!!

Thanks!!

running tightvnc server on display:0

hello all i am trying to run the tightvnc or real vnc on display/ terminal:0 can anybody tell me how to run

by default is is running on display:1 ever passing the value display:0

thanks in advance

If you're just wanting to run

If you're just wanting to run it on port 5900, you can change the DISPLAY variable to 0. However, if you want to attach to an existing X11 server (instead of spawning a separate desktop), you can use the built-in Gnome VNC server (vino-server) or the highly-configurable and quite excellent x11vnc.

I needed to replace

I needed to replace

icewm-session &

with

startxfce4

to get XFCE4 running under Ubuntu 10.04

Great tutorial - thanks

Thanks

Works like a charm on Ubuntu server 11.10

Here is an update for this

Here is an update for this article that helped me out on Ubuntu 11.04: http://zatansuibi.blogspot.com/2011/06/vnc-set-up-in-ubuntu.html

Andrew, you're a god! I spent

Andrew, you're a god! I spent over a day wasting time reading and reading and reading, and experimenting. Just like the previous Anonymous said, so many permutations of useless info...then this. Thank you, I can finally put my server online and get some sleep! My fiancee and child owe you a thanks...

Still Works

Used this guide to setup automatic run for 2 users on Maverick. I didn't need to fix anything. I simple copy and pasted from the guide to an ssh session on a remote desktop, fixed the user name & screen number. Saved and fixed the permissions. It started without issue, and installed for run at boot without complaint.

Fantastic guilde and still very usable.

Really nice, Thanks for this

Really nice, Thanks for this

Start a VNC Server on Ubuntu on Boot

I was getting an error after doing
sudo update-rc.d vncserver defaults
So I changed /etc/init.d/vncserver to as the error was suggesting
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6

I was not able to start it without rebooting with
sudo /etc/init.d/vncserver start
However I decided to just reboot and its working just fine.

Thanks for the information.

Clipboard from client not working

The solution is great! I use ubuntu 11.10 and finally don't need to login locally to X everytime I boot my server to enable vnc. I don't know how come the developers don't allow users to at least choose to run vnc server on boot and not after logging in. For headless servers it is so normal. And Microsoft remote desktop does just that without complaining... This is so lame...

Anyway, thanks for the article. I just bumped into one problem. I noticed that by default my clipboard (windows 7) is not shared with the server. I googled a site advising to use autocutsel

http://thomas.patrickdepinguin.com/knowledgebase/tight-vnc

However, the recommended command line

autocutsel -s PRIMARY -fork

did work only one-way, i.e. from server to client.

When I changed the -s parameter to

autocutsel -s CLIPBOARD -fork

it worked perfectly both ways!

Was getting the help screen

Was getting the help screen until changed su to echo to see what was getting run.

Self inflicted stupidity, but need to escape quote the name if you have spaces in $NAME:
OPTIONS="-name\"${NAME}\" -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

Similar advice for RedHat and Suse

Andrew,

Thanks for these useful instructions which seem to work find for Debian/Ubuntu, but they need a little bit of tweaking to work with RedHar or Ubuntu (see my blog post http://www.brianodonovan.ie/2011/11/automatically-starting-vnc-server-at... for details)

Brian

Thanks a lot

I do not know how many hours I saved following your instructions. You wrote really a great post.
Thanks again.

Useful!

Thanks, this helped get me going me when vino started crashing in Ubuntu 11.10

One thing - there is a typo

sudo -i && cat > /etc/init.d/vncserve && exit

should be

sudo -i && cat > /etc/init.d/vncserver && exit

Thanks for catching that -

Thanks for catching that - impressive on a 3 and a half year old article!

Great, but ...

Thank you, I'm up and running on Ubuntu 11.10 32-bit.

Two problems - first is this bug where the letter 'd' closes all open windows - https://bugs.launchpad.net/ubuntu/+source/vnc4/+bug/658723, but you can fix this by going into System Settings --> Keyboard --> Shortcuts --> Hide all normal windows*
Change this to SHIFT-ALT-D, or whatever.

Second problem still unsolved is that the icons in Unity are not displaying properly, some do, some don't. For example if I open up 'Network Connections' my wired LAN does appear. Another example is the Terminal icon on the Unity bar - I can click on it but it is just an empty black icon.

Anyone know how to fix this?

Cheers

Awesome

Worked great! Thank you.

When I run vncserver I get an

When I run vncserver I get an error that says:

vncpasswd: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

Do you know how to fix this?

Don't bother

Wasted hours on this, doesn't work.

yep. doesn't work.

yep. doesn't work.

Ubuntu 11.10 - gave up after 2 weeks.

I hope this might be of help.

My solution:
1 - Go to the desktop sharing and allow it to sharing and put a good password.
(click off to allow permissions)
2 - Go to the Screen and set it to lock after 30 seconds.
3 - Go to users and allow an automatic login.

The vino server starts and you should be able to attach to it. You can use ssh to create a tunnel for VNC if you need to secure it (I used PUTTY and that worked very well). You can also enable the firewall and just allow traffic from a specific address. This solution has worked for me in over 20 Ubuntu boxes.

Get error starting vnc server

I followed all the direction till I got to the command on line 6. When I ran that it did not like the NAME=”vicbitter” so I changed it to NAME=”giles” so I tried NAME=”giles@vicbitter” each time I got the following error.
"/etc/init.d/vncserver: 30: ”giles@vicbitter”: not found" . The vncserver that started was a local one at Starting applications specified in /home/giles/.vnc/xstartup
Log file is /home/giles/.vnc/vicbitter:1.log

Any help appresiated

Get error starting vnc server

Just like to add to the above that the vnc server does not start on reboot either??

Only getting a black screen with X pointer

Hey guys i followed these steps but all i get is a Black screen with a X shaped pointer that can be moved by mouse :/

Any solutions ?

Debian 6.0

Your article is great ! Thank you !
For those who might to try this under Debian 6.0 Squeeze some rework of the script is needed :

change the header to look like this

#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO

Do not use update-rc.d but insserv

Thank you

Thank you, Thank you, Thank you

Authentication Issues

It all seems to work, but when I try and use Synaptic (as an example) it doesn't load the auth prompt, presumably it's trying with a text prompt (it does when I run synaptic-pkexec from the terminal)

I'm guessing that this is a security feature to prevent su from dropping to whoever, but is there a way around this? or am I doing something wrong?

starting thightvncserver in Raspberry PI Debian zqueeze.

I didn't have to do all those steps exposed in this headlines,

What it did the job for me was:

sudo nano /etc/rc.local

And add this line somewhere in the middle or beginning:

su -c "/usr/bin/tightvncserver -geometry 1280x1024" username

Before I had included other options/parameters in that line and I was getting black icons on the screen, but with only -geometry option did the trick and it work great!

VNC server start at boot

Thank you! Thanks, and thanks again! This is the quickest and best solution for getting the server up and running at boot. I wish I had found it earlier.

still having a useless grey vnc client !!!!

I tried to follow these instructions in order to configure "Ultravnc viewer" on a wondows vista system (with an intel integrated graphics card with 32bits color/ 1280x800 / 59HTZ) in order to manage an ubuntu 10.04 64bits system (the desktop amd64 bits install from the main ubuntu repository).

went through all the steps but I still have a grey screen on ultravnc viewer which blocks me from using the tool??

tried to install other tools (clients) such as VNC viewer and tightvnc viewer ,but they all end up with a grey interface!!!
I tried different settings " geometry 800x600/1280x1024/1024x768" ,but still stuck with this grey screen!!

Any suggestions please??

thank you for share it's done

thank you for share
it's done

I wish I didn't have to do this kind of stuff

When I install tightvncserver from the Ubuntu 13.04 repository, why isn't it already set up as a "proper server", (starting automatically at clean boot or reboot), obviating the need for your article? I mean what is the point of a server that you have to launch yourself? - especially since you have to use ssh (a proper server that does launch automatically) to do it. Is it because the Ubuntu developers are a bunch of amateurs ?

My Apache2 box uses LXDE desktop, and doesn't have /usr/X11R6/bin/ , so what do I put in PATH="$PATH:..." ?

Do I have to change Line 3 to:
# Provides: tightvncserver

Login problems

I followed the tutorial, and ran all the needed commands.

I ran update-rc.d vncserver defaults, then went back to the vncserver script in init.d and changed display to 0, saved, and rebooted.

Once it was booted, I tried connecting using VNC Viewer. When I tried to connect, the connection was refused. So, I went to the server itself, and it was at the login screen. I logged in, but the screen went black for about a second, then came back at the login screen.

I can no longer log in, and therefore cannot really do anything to the server anymore.

How can I fix this?

Login problems

I followed the tutorial, and ran all the needed commands.

I ran update-rc.d vncserver defaults, then went back to the vncserver script in init.d and changed display to 0, saved, and rebooted.

Once it was booted, I tried connecting using VNC Viewer. When I tried to connect, the connection was refused. So, I went to the server itself, and it was at the login screen. I logged in, but the screen went black for about a second, then came back at the login screen.

I can no longer log in, and therefore cannot really do anything to the server anymore.

How can I fix this?

Thanks for your tuto. I

Thanks for your tuto. I tried on ubuntu server 14.04 and kde (kubuntu-desktop).
It's working fine using windows client tightvnc viewer except that when I logout (Leave - Log Out) the screen becomes (and remains) black. Only solution connect with ssh and do killall -u ...
What's wrong ?

Logout not working ...

Thanks for your tuto. I tried on ubuntu server 14.04 and kde (kubuntu-desktop).
It's working fine using windows client tightvnc viewer except that when I logout (Leave - Log Out) the screen becomes (and remains) black. Only solution connect with ssh and do killall -u ...
What's wrong ?