Linux/VNC

From Omnia
Jump to: navigation, search

vnc

Virtual Network Computing

vncserver

vncserver uses realvnc or tightvnc

Simple Setup

Simple setup:

$ service vncserver start
$ vncpasswd
$ vncserver

Installation

yum install vncserver xterm twm

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

KDE

To start KDE automatically:

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

Sample KDE xstartup file

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# 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 &

GNOME

To start GNOME automatically:

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

xfce4

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

~/.vnc/xstartup:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# 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 &

Fix tab: [1]

  • Clearing this key from xfce4-settings-manager => window manager => keyboard fixes the problem, OR...
  • xfconf-query -c xfce4-keyboard-shortcuts -p /xfwm4/custom/'<'Super'>'Tab -r

twm

Tab Window Manager

twm - mouse

yum install vncserver xterm twm
apt-get install xterm twm

~/.vnc/xstartup:

...
twm &
xterm &

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

/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 &

References

Virtual Network Computing

TightVNC

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

apt-get install tightvncserver

Remote Desktop Sharing

Vino

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/vsrv.sh << "EOF"
## #!/bin/bash
## /usr/lib/vino/vino-server
## EOF
## chmod +x /etc/sudoers.d/vsrv.sh
## 
## cat >> /etc/xdg/lxsession/LXDE/autostart << "EOF"
## @/etc/sudoers.d/vsrv.sh
## 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

Screen Capture

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:

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/

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