Linux/VNC

vnc
Virtual Network Computing

vncserver
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

Installation
yum install vncserver xterm twm yum install tigervnc-server xterm
 * 1) centos 7:

apt install tightvncserver

To hide vnc settings window
Change: (~/.vnc/xstartup) vncconfig -nowin -iconic &
 * 1) vncconfig -iconic &

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

KDE
To start KDE automatically: $ vi ~/.vnc/xstartup # replace "twm &" with... startkde &

Sample KDE xstartup file

 * 1) !/bin/sh


 * 1) Uncomment the following two lines for normal desktop:
 * 2) unset SESSION_MANAGER
 * 3) 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 & startkde &
 * 1) xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
 * 2) twm &

GNOME
To start GNOME automatically: $ vi ~/.vnc/xstartup # replace "twm &" with... exec gnome-session &

xfce4
yum install xfce4-session xfce-utils apt-get install vnc4server xfce4

yum install epel-release -y yum install xfce4-session
 * 1) CentOS 7:
 * 1) yum groupinstall "Xfce"

~/.vnc/xstartup:
 * 1) !/bin/sh


 * 1) Uncomment the following two lines for normal desktop:
 * 2) unset SESSION_MANAGER
 * 3) 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 & xfconf-query -c xfce4-keyboard-shortcuts -p /xfwm4/custom/'<'Super'>'Tab -r startxfce4 & xterm &
 * 1) vncconfig -iconic &
 * 2) x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
 * 3) x-window-manager &
 * 1) xfce4-session &

Ubuntu: (auto configured after installing xfce)
 * 1) !/bin/sh

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

---

Fix tab completion not working:
 * 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

https://www.starnet.com/xwin32kb/tab-key-not-working-when-using-xfce-desktop/

https://bugzilla.xfce.org/show_bug.cgi?id=10760

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

-

https://www.smork.info/blog/2015/06/10/fixing_bash_tab_completion_in_xfce.html

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

Find this line:  Change it to this:  Restart the VNC server: vncserver -kill :1 vncserver

-

https://stackoverflow.com/questions/23418831/command-line-auto-complete-tab-key-not-work-in-terminal-for-ubuntu

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

 to 

Reboot or restart your VNC server (XFCE).

twm
Tab Window Manager

twm - mouse

yum install vncserver xterm twm apt-get install xterm twm

~/.vnc/xstartup: ... twm & xterm &

If you get errors with fonts: LANG=C twm

Kill VNC Server
To kill a VNC server: vncserver -kill :xxx
 * 1) where xxx is the display number (ie. :1)

SSH tunnel
SSH multiple tunnel: For example the the first tunnel would be: ssh -L 5901:localhost:4321 @ and then on the gateway machine ssh -L 4321:localhost:5901 @ 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 /etc/sysconfig/vncservers and add your users line on the bottom: VNCSERVERS="1:Username"

Using usernames to login
Simplifying Remote VNC Logins

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

DISPLAY
export DISPLAY=:0 xterm &

TightVNC
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:

Resize VNC Session
Great for headless:

vnc_resize.sh:
 * 1) !/bin/bash

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

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

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

echo $MODELINE 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

Vino
sudo apt-get install vino dconf-editor

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


 * 1) sudo su -
 * 2) cat > /etc/sudoers.d/vsrv.sh << "EOF"
 * 3) #!/bin/bash
 * 4) /usr/lib/vino/vino-server
 * 5) EOF
 * 6) chmod +x /etc/sudoers.d/vsrv.sh
 * 7) cat >> /etc/xdg/lxsession/LXDE/autostart << "EOF"
 * 8) @/etc/sudoers.d/vsrv.sh
 * 9) EOF
 * 1) EOF

sudo su - cat > /etc/xdg/autostart/vino-server.desktop << "EOF" [Desktop Entry] Name=Desktop Sharing Comment=GNOME Desktop Sharing Server Exec=/usr/lib/vino/vino-server Terminal=false Type=Application X-GNOME-Autostart-Phase=Applications X-GNOME-AutoRestart=true NoDisplay=true EOF

RPi VNC Screen Sharing - eLinux.org - http://elinux.org/RPi_VNC_Screen_Sharing

vncdo
sibson/vncdotool · GitHub - https://github.com/sibson/vncdotool

"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

--

Install: pip install vncdotool

--

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

--

More examples of usage:
 * Usage — VNCDoTool 0.9.0.dev0 documentation - http://vncdotool.readthedocs.org/en/latest/usage.html

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 - https://pypi.python.org/pypi/vncdotool/0.2.0

vncsnapshot
VNC Snapshot - http://vncsnapshot.sourceforge.net/
 * VNCSnapshot | SourceForge.net - http://sourceforge.net/projects/vncsnapshot/

"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."

Example: 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.