From Omnia
Jump to navigation Jump to search


Virtual Network Computing


vncserver uses realvnc or tightvnc

Simple Setup

Simple setup:

$ service vncserver start
$ vncpasswd
$ vncserver

To set password to empty: (need to have at least started vncserver once to get configs in place)

echo "" | vncpasswd -f > ~/.vnc/passwd


yum install vncserver xterm twm
# centos 7:
yum install tigervnc-server xterm
apt install tightvncserver

To hide vnc settings window

Change: (~/.vnc/xstartup)

#vncconfig -iconic &
vncconfig -nowin -iconic &

Also comment out the "xterm -geometry..." line so terminal doesn't start automatically.

Desktop Mangager


To start KDE automatically:

$ vi ~/.vnc/xstartup
  # replace "twm &" with...
  startkde &

Sample KDE xstartup file


# Uncomment the following two lines for normal desktop:
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -nowin -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startkde &


To start GNOME automatically:

$ vi ~/.vnc/xstartup
  # replace "twm &" with...
  exec gnome-session &


yum install xfce4-session xfce-utils
apt-get install vnc4server xfce4
# CentOS 7:
yum install epel-release -y
#yum groupinstall "Xfce"
yum install xfce4-session



# Uncomment the following two lines for normal desktop:
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
#vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
vncconfig -nowin -iconic &
xfconf-query -c xfce4-keyboard-shortcuts -p /xfwm4/custom/'<'Super'>'Tab -r
#xfce4-session &
startxfce4 &
xterm &

Ubuntu: (auto configured after installing xfce)


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


Fix tab completion not working: [1]

  • Clearing this key from xfce4-settings-manager => window manager => keyboard fixes the problem, OR...
    • Application Menu > Settings > Window Manager > Keyboard > clear "Switch window for same application"
  • xfconf-query -c xfce4-keyboard-shortcuts -p /xfwm4/custom/'<'Super'>'Tab -r

See Xfce bug 10760

To fix this,

  • Open the Xfce Application Menu > Settings > Window Manager
  • Click on the Keyboard Tab
  • Clear the Switch window for same application setting


Edit the file ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

Find this line:

<property name="<Super>Tab" type="string" value="switch_window_key"/>

Change it to this:

<property name="<Super>Tab" type="empty"/>

Restart the VNC server:

vncserver -kill :1


Disable the behaviour of tab changing windows. This is done in the file ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml by changing the line

<property name="<Super>Tab" type="string" value="switch_window_key"/>


<property name="<Super>Tab" type="empty"/>

Reboot or restart your VNC server (XFCE).


Tab Window Manager

twm - mouse

yum install vncserver xterm twm
apt-get install xterm twm


twm &
xterm &

If you get errors with fonts:

LANG=C twm

Kill VNC Server

To kill a VNC server:

# where xxx is the display number (ie. :1)
vncserver -kill :xxx

SSH tunnel

SSH multiple tunnel:

For example the the first tunnel would be:
ssh -L 5901:localhost:4321 <user>@<gateway.machine>
and then on the gateway machine
ssh -L 4321:localhost:5901 <user>@<server.machine>

After setting up the tunnels, you can start the VNC client as usual
vncviewer -shared localhost:1 

Autostart VNC for Select User

If you want to access your server via VNCServer, you can automatically start the VNCServer at startup. You have to select a user under which the server will be running. Then, edit


and add your users line on the bottom:


Using usernames to login

Simplifying Remote VNC Logins

You will need to configure GDM to accept remote login requests.


export DISPLAY=:0
xterm &


Virtual Network Computing


TightVNC: VNC-Compatible Free Remote Control / Remote Desktop Software - TightVNC: VNC-Compatible Free Remote Control / Remote Desktop Software

apt-get install tightvncserver

Set Resolution

vncserver -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768

Then resize with:

xrandr -s 1600x1200
xrandr -s 1440x900
xrandr -s 1024x768


If you need to change the setting without restarting VNC server, I had good results with:

vncconfig -set RandR="1024x768,1600x900"

and then using xrandr to change resolution as fgregg suggested:

xrandr -s 1024x768
xrandr -s 1600x900


Ref: [2]

Resize VNC Session

Great for headless:


if [ "$1" == "" -o "$2" == "" ] ; then
  echo "Usage: [width] [height]"
  exit 1

DISP=`xrandr --prop | grep connected`
if [ $? -ne 0 ] ; then
  echo "Run this from graphics session"
  exit 1

MODELINE=`cvt $1 $2 | tail -n 1 | sed 's/Modeline //'`
MODE=`echo $MODELINE | awk '{print $1}'`
DISP=`echo $DISP | awk '{print $1}'`

echo $MODE
echo $DISP

xrandr --newmode $MODELINE
xrandr --addmode $DISP $MODE
xrandr --fb $1x$2

1. Calculate the Modeline:

$ cvt 1440 900
Modeline "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsyn

2. Create mode:

$ xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync

3. Find Display:

xrandr --prop
   VGA-0 ...

4. Add Mode:

$ xrandr --addmode VGA-0 "1440x900_60.00"

5. Set Mode:

xrandr --fb 1440x900

Remote Desktop Sharing


sudo apt-get install vino dconf-editor

# as pi user...
gsettings set org.gnome.Vino require-encryption false
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino authentication-methods "['none']"

## sudo su -
## cat > /etc/sudoers.d/ << "EOF"
## #!/bin/bash
## /usr/lib/vino/vino-server
## EOF
## chmod +x /etc/sudoers.d/
## cat >> /etc/xdg/lxsession/LXDE/autostart << "EOF"
## @/etc/sudoers.d/
## EOF

sudo su -
cat > /etc/xdg/autostart/vino-server.desktop << "EOF"
[Desktop Entry]
Name=Desktop Sharing
Comment=GNOME Desktop Sharing Server

RPi VNC Screen Sharing - -

Screen Capture


sibson/vncdotool · GitHub -

"vncdotool is a command line VNC client. It can be useful to automating interactions with virtual machines or hardware devices that are otherwise difficult to control."

Screen capture:

vncdo -s myserver:0 -p mypassword capture 1.png capture 2.png



pip install vncdotool



vncdo -s vncserveraddress type "hello world"
vncdo -s vncservername capture screen.png


More examples of usage:

Putting it all together you can specify multiple actions on a single command line. You could automate a login with the following:

> vncdo type username key enter expect password_prompt.png
> vncdo type password move 100 150 click 1 expect welcome_screen.png


pypi - vncdotool 0.2.0 : Python Package Index -


VNC Snapshot -

"VNC Snapshot is a command line utility for VNC (Virtual Network Computing) available from RealVNC, among others. The utility allows one to take a snapshot from a VNC server and save it as a JPEG file. Unix, Linux and Windows platforms are supported."


vncsnapshot some_server:1 -passwd vnc_passwd_file screenshot.jpg

Note: Read encrypted password from filename instead of from the console. The filename can be made with the vncpasswd utility included in the vncsnapshot distribution.