Thursday 14 March 2013

VNC server on Linux

Setup VNC server on a Linux machine


Login with the user for which you want to allow remote desktop and enable vncserver startup from System ->Administration->Server Settings->Service configuration
Add the following lines to /etc/sysconfig/vncservers
VNCSERVERS="1:#username#”
VNCSERVERARGS[1]="-geometry 1024x768 -depth 16"
where #username# is the name of the user for which you want to allow remote desktop.
Start and stop VNC server to create the VNC startup file /home/ciuser/.vnc/xstartup
vncserver :1
vncserver -kill :1
The of /home/#username#/.vnc/xstartup must be as follows
#!/bin/sh

vncconfig -iconic &

# 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
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
Copy & Paste the lines above into /home/#username#/.vnc/xstartup where #username# is the name of the user for which you want to allow remote desktop.
 vncserver uses the ports 5901 for display :1, 5902 for display :2, and so on.

The sessions are available on ports 5901 for regular VNC viewers (equivalent to VNC display 1) and on port 5801 for Web browsers. 
For example, in the browser you can access a machine with VNC server running:
http://machineName:5801 
which is equal to using a VNC desktop client, on this one you will use
machineName:5901

No comments:

Post a Comment