VNC
Virtual Network Computing (VNC) is a system that allows you to control a remote computer graphically using the RFB protocol.
TightVNC, Vino, and X11vnc are some of the remote access programs via VNC available for Linux. In this post, I will talk about TightVNC.
- 
Install TightVNC:julio@julio-acer ~ $ sudo pacman -S tightvnc
- 
Create the initial files and set an access password julio@julio-acer ~ $ vncserver :1 You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? n New 'X' desktop is julio-acer:1 Creating default startup script /home/julio/.vnc/xstartup Starting applications specified in /home/julio/.vnc/xstartup Log file is /home/julio/.vnc/julio-acer:1.logBy default, the server will run on TCP port 5900+n, where n is the display number. 
- 
To start the configurations, kill the running server julio@julio-acer ~ $ vncserver -kill :1
- 
Edit the configuration file, similar to .xinitrc julio@julio-acer ~ $ vim ~/.vnc/xstartup #!/bin/sh export XKL_XMODMAP_DISABLE=1 #Evita erro ao mapear o teclado exec startxfce4 #exec awesome
- 
For security, allow only local connections, so if someone wants to connect to the computer remotely, they will have to authenticate via ssh. To allow only local connections, simply start the vncserverwith the-localhostoption:vncserver -localhost :1
- 
Start and stop the VNC server automatically - 
Start VNC server when turning on the computer: julio@julio-acer ~ $ sudo vim /etc/rc.local su julio -c "vncserver -localhost :1"
- 
Stop VNC server when turning off the computer: julio@julio-acer ~ $ sudo vim /etc/rc.local.shutdown su julio -c "/usr/bin/vncserver -kill :1"
 
- 
Connecting from another computer
$ ssh -p 22 julio@casa.juliobs.com -L 8900/localhost/5901
Where I put -p 22, change the port to the number you use for SSH. The -L option sets up the SSH
tunneling. Then run vncviewer localhost:8900.
Connecting via iPhone
The iSSH app has the option to connect directly via VNC (RAW), but as already explained, it is safer to use SSH tunneling.
- 
Open iSSH.
- 
Go to Add Configuration…and set it up similar to the following configuration:(image not available)
- 
Go back to the program’s main screen and choose the configuration you just created. (image not available)Since we are using an iPhone 3G with a resolution of 480x320 (the iPhone 4 has a screen resolution of 960x640), it may be interesting to configure TightVNCto resize the screen to get a complete view of the environment.Start the server with the -geometryoption. For landscape view:julio@julio-acer ~ $ vncserver -localhost -geometry 480x268 :1I took off 52 pixels from the height to compensate for the top part of the screen. For portrait view: julio@julio-acer ~ $ vncserver -localhost -geometry 320x416 :1
Sometimes I also want to be able to control the same display being shown on the remote computer or
simply monitor the programs that are running. This is not possible with TightVNC, but it is easily
done with X11vnc.
- 
Install X11vnc julio@julio-acer ~ $ sudo pacman -S x11vnc
- 
If you want, set a .Xauthorityjulio@julio-acer ~ $ x11vnc -display :0 -auth ~/.Xauthority
- 
Set a password julio@julio-acer ~ $ mkdir ~/.x11vnc julio@julio-acer ~ $ x11vnc -storepasswd your_password_here ~/.x11vnc/passwd stored passwd in file: /home/julio/.x11vnc/passwd
- 
Just like with TightVNC, use the-localhostoption for security.In summary, the VNC server can be accessed using the following script, which you may want to place in the .xinitrc:julio@julio-acer ~ $ x11vnc -localhost -many -display :0 -auth ~/.Xauthority &>/dev/null &The -manyoption prevents the server from shutting down when you end the session.
- 
Access through SSH tunnel julio@server ~ $ ssh -p 22xx -t -L 5900:localhost:5900 casa.juliobs.com 'sudo x11vnc -display :0 -auth /home/julio/.Xauthority'
- 
Access from iPhone is exactly the same as with TightVNC, but here we use port5900.
Issues:
Apparently, TightVNC does not support RandR, which is necessary to change the screen resolution
and open some programs like Chromium and Firefox. There are some patches on the internet to solve
the problem. Another program that seems to support RandR is RealVNC.