Introduction: TightVNC used to run well as a Service in openSUSE about 5 years ago. TightVNC hasn’t worked properly since advanced DEs began with the early releases of KDE4, years ago. I noticed today that it’s working again so I thought I should post some notes on how to to get it working.
There are some official ref notes on the Net:Internet Docs (but they still don’t work for me. Maybe they’ll work for you, so it’s worth a read).
Software: I have openSUSE 12.3 and the VNC software is included by default. If you have any suspicions that you are short a few RPMs, here’s what was installed by default in mine:
barack@webserver123:~> rpm -qa | grep vnc
remmina-plugin-vnc-1.0.0-6.4.1.x86_64
xorg-x11-Xvnc-7.6_1.0.1-3.12.1.x86_64
tightvnc-1.3.10-10.4.1.x86_64
I used XFCE as the DE in this experiment. I assume it’s about the same in the other DEs, but let me know if it’s not and I’ll make adjustments.
Firewall (SuSefirewall2): Open Yast → Security and Users → Firewall.
- Set to start at boot.
- Set interfaces in the External Zone.
- In Allowed Services, use the drop-down to select VNC and Add it to the Allowed Services panel.
- Then click Next to lock it in.
That opens the TCP ports 5900 to 5999, so you can open any of those 100 channels in your “vncserver” command.
Initialise VNC Server: Open a console and run this simple command not as root, just as yourself, ordinary user: vncserver. That will initiate a one-time password dialogue where you will be asked to supply two passwords. The first is for read/write access to the server, the second is for read-only access to the server (i.e as an observer only). You don’t have to make a second password if you don’t want to.
Adjust the Server config file. The config file is named xstartup and is located in the hidden folder /home/barack/.vnc. It’s an executable shell script.
These are the default contents:
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
For the XFCE DE change the contents to these:
#!/bin/sh
dbus-launch /usr/bin/startxfce4
For the KDE DE change the contents to these:
#!/bin/sh
dbus-launch /usr/bin/startkde
How to start the Server, including colour depth and geometry
Here’s the reference page: TightVNC: Manual Page for Xvnc(1)
You can include port number, colour depth and geometry like this: vncserver :2 -depth 16 -geometry 1900x1060
(You use normal commands, not root commands). VNC is really bad with the “geometry” parameter. I usually leave it out and it will more or less adopt the aspect ratio of the current screen on the server – and then I can adjust the magnification or contraction as percentages on the client machine using the Connection Options tool on the Client machine.
Here’s an example of starting the server:
barack@webserver123:~> vncserver :2 -depth 16
New 'X' desktop is webserver123.site:2
Starting applications specified in /home/barack/.vnc/xstartup
Log file is /home/barack/.vnc/webserver123.site:2.log
How to stop the server: vncserver -kill :2
Here’s an example:
barack@webserver123:~> vncserver -kill :2
Killing Xvnc process ID 2867
barack@webserver123:~>
Running VNC Server as a permanent Service
You have to use a normal username to get a non-root DE served to the client machine. But don’t use any of the common DE user-autostart methods found in KDE, Gnome or XFCE etc. They start infinite loops of desktops and crash your system. Do this instead:
You can get around the looping issue with a Cron job: create an entry in your personal crontab (not root’s crontab). The line for the cron job is like this:
@reboot sleep 15; /usr/bin/vncserver -depth 16
Voilà
Be well
swerdna