VNC

Virtual Network Computing (VNC) is a system that lets you control a remote computer graphically over the RFB protocol.
TightVNC, Vino and X11vnc are some of the VNC remote access programs available for Linux. In this post I will talk about TightVNC.
Install
TightVNC:julio@julio-acer ~ $ sudo pacman -S tightvncCreate 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 runs on TCP port 5900+n, where n is the display number.
To start configuring, kill the running server
julio@julio-acer ~ $ vncserver -kill :1Edit the configuration file, much like .xinitrc
julio@julio-acer ~ $ vim ~/.vnc/xstartup #!/bin/sh export XKL_XMODMAP_DISABLE=1 #Avoids an error when mapping the keyboard exec startxfce4 #exec awesomeFor safety, allow local connections only, so that anyone wanting to connect to the computer remotely has to authenticate over ssh.
To allow only local connections, just start
vncserverwith the-localhostoption:vncserver -localhost :1Starting and stopping the VNC server automatically
Start the VNC server when the computer boots:
julio@julio-acer ~ $ sudo vim /etc/rc.local su julio -c "vncserver -localhost :1"Stop the VNC server when the computer shuts down:
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 does the SSH
tunneling. Then run vncviewer localhost:8900.
Connecting from the iPhone
The iSSH app has the option of connecting over VNC directly (RAW), but as already explained, SSH tunneling is safer.
Open
iSSHGo to
Add Configuration…and make it look like the following configuration:(image unavailable)Go back to the program’s home screen and pick the configuration you just created.
(image unavailable)Since we are using an iPhone 3G with a 480x320 resolution (the iPhone 4 has a 960x640 screen), it can be worth configuring
TightVNCto resize the screen so we get a full view of the desktop.Start the server with the
-geometryoption. For landscape view:julio@julio-acer ~ $ vncserver -localhost -geometry 480x268 :1I took about 52 pixels off the height to make up for the top of the screen.
For portrait view:
julio@julio-acer ~ $ vncserver -localhost -geometry 320x416 :1
Sometimes I also want to control the same display that is being shown on the remote computer, or
simply to monitor the programs that are running. That is not possible with TightVNC, but it is
easily done with X11vnc.
Install X11vnc
julio@julio-acer ~ $ sudo pacman -S x11vncIf you like, set an
.Xauthorityjulio@julio-acer ~ $ x11vnc -display :0 -auth ~/.XauthoritySet a password
julio@julio-acer ~ $ mkdir ~/.x11vnc julio@julio-acer ~ $ x11vnc -storepasswd your_password_here ~/.x11vnc/passwd stored passwd in file: /home/julio/.x11vnc/passwdJust as with
TightVNC, use the-localhostoption for safety.In short, the VNC server can be reached with the following script, which you may want to put in
.xinitrc:julio@julio-acer ~ $ x11vnc -localhost -many -display :0 -auth ~/.Xauthority &>/dev/null &The
-manyoption keeps the server from shutting down when you end the session.Connect through the SSH tunnel
julio@servidor ~ $ ssh -p 22xx -t -L 5900:localhost:5900 casa.juliobs.com 'sudo x11vnc -display :0 -auth /home/julio/.Xauthority'Access from the iPhone works exactly the same way as with
TightVNC, but here we use port5900.
Problems:
Apparently tightVNC does not support RandR, which is needed to change the screen resolution and
to open some programs such as Chromium and Firefox. There are a few patches on the internet that
solve the problem. Another program that seems to support RandR is RealVNC.
Links

I’m a Brazilian-German computer engineer based in Germany, passionate about tech, science, photography, and languages.
I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.
I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, serving on the PSF D&I Work Group, mentoring, and contributing code and translations.
On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.
Browse my gallery for some of my photography.
Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.
Always happy to connect! 🙂