Install VNC on Debian

For a KDE Desktop run via VNC,

On the server:

apt-get install kde-plasma-desktop tightvncserver xtightvncviewer

Debian Wiki states that for a full KDE installation, one needs to do this:

aptitude install ~tkde-desktop

For LXDE:

apt-get install task-lxde-desktop

Create a user:

useradd -c "Tightvnc user" -m -r -s /bin/bash vncuser
sudo -iu vncuser bash
unset XAUTHORITY
vncserver

Now, create a vncserver instance:

vncserver :1 -geometry 1356x758 -depth 16 -pixelformat rgb565

If you weren’t prompted for a password, set a password for vnc with:

vncpasswd

If you need to reset the server:

tightvncserver -kill :1

Now, edit the file: /root/.vnc/xstartup

Find the line:

gnome-session &

and replace it with:

startkde &

if you prefer kde.

For lxde, the file looks like this:

#cat /root/.vnc/xstartup
#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
lxterminal &
/usr/bin/lxsession -s LXDE &

Optionally setup an alias in .bashrc, and assign:

alias startvnc='vncserver :1 -geometry 1366x676 -depth 16 -pixelformat rgb565'
alias killvnc='tightvncserver -kill :1'
#alias startvnc='vncserver :1 -geometry 1356x758 -depth 16 -pixelformat rgb565'

On Windows, install TightVNC, and connect to url: yourserverip:5901

To enable Copy Paste between Windows and the VNC instance, try this:
Add the following lines to /root/.vnc/xstartup before /usr/bin/lxsession -s LXDE & :

vncconfig  -nowin &
export XKL_XMODMAP_DISABLE=1
autocutsel -fork

The final file for LXDE now looks like this:

#cat /root/.vnc/xstartup
#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1

vncconfig  -nowin &
export XKL_XMODMAP_DISABLE=1
autocutsel -fork

/etc/X11/Xsession
lxterminal &
/usr/bin/lxsession -s LXDE &

Now you can copy something in Windows and paste into Tightvnc.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.