VNC stands for Virtual Network Computing or in simple terms its 'Remote Desktop'. It allows a system to access the desktop of another system. Now lets see how vnc can be done on ubuntu.
$ sudo apt-get install vnc4server xvnc4viewer
1. vnc4server - This is the vnc server application. It is run on the system which is to be viewed remotely.
2. xvnc4viewer - This is the client application. It will connect to a remote vnc system.
Setup the vnc password
The vnc client that will connect to this vnc server will need to use a password. Hence a password must first be setup. This can be done using the vncpasswd command. Remember that the password file is located at ~/.vnc/passwd
$ vncpasswd ~/.vnc/passwd Password: Verify:
Or you can simply run the vncpasswd command only
$ vncpasswd Password: Verify:
Launch the vnc server
desktop:~$ vncserver :12 -geometry 1024x768 New 'enlightened-desktop:12 (enlightened)' desktop is enlightened-desktop:12 Starting applications specified in /home/enlightened/.vnc/xstartup Log file is /home/enlightened/.vnc/enlightened-desktop:12.log
The :12 is the display number. It can be any number and will open vncserver on that number. You can have multiple vncservers running. If you are running vncserver command for the first time it will ask for a password.
Connect using VNC Client
Once vncserver is running , its time to run the vnc client.
$ vncviewer localhost:12 VNC Viewer Free Edition 4.1.1 for X - built Feb 5 2012 20:01:21 Copyright (C) 2002-2005 RealVNC Ltd. See http://www.realvnc.com for information on VNC. Tue Aug 7 18:27:59 2012 CConn: connected to host localhost port 5912 CConnection: Server supports RFB protocol version 3.8 CConnection: Using RFB protocol version 3.8 Password:
It will first ask for the server. Enter localhost:12 . The format can be ipaddress:display_number
Next it will ask for the password. Use the password that was setup in the previous steps.
Now a VNC window will open up with a terminal showing.
The man page of xvnc4viewer says :
If you run the viewer with no arguments it will prompt you for a VNC server to connect to. Alternatively, specify the VNC server as an argument, e.g. :
where 'snoopy' is the name of the machine, and '2' is the display number of the VNC server on that machine. Either the machine name or display number can be omitted. So for example ":1" means display number 1 on the same machine, and "snoopy" means "snoopy:0" i.e. display 0 on machine "snoopy".
If the VNC server is successfully contacted, you will be prompted for a password to authenticate you. If the password is correct, a window will appear showing the desktop of the VNC server.
Close server after finishing
After the vnc session is complete the vnc server should close the display.
$ vncserver -kill :12 Killing Xvnc4 process ID 23664
The above approach of establishing a vnc connection has certain limitations. It requires the server machine to have a publicly accessible IP address or have the necessary port forwarding setup so that vnc client can reach it on the correct port number.
In reverse vnc, the vnc server connects to the vnc client. This is done when the server neither has a public ip, nor can do port forwarding. However the client must have a public ip or must be able to do the necessary port forwarding. 1. https://help.ubuntu.com/community/VNC
In reverse vnc, the vnc server connects to the vnc client. This is done when the server neither has a public ip, nor can do port forwarding. However the client must have a public ip or must be able to do the necessary port forwarding.