Setup a Remote GUI on Linux Using VNC Server
There are some times when having a remote GUI console can be very helpful. You may want to use the GUI interface for configuring the machine or to use applications. I know personally, I like that I can login to VNC and startup a terminal window and start a job and then come back later and check on its progress. All of this without tying up my laptop. Other times, it is nice to just use the Gnome Desktop for some tasks. Whatever the reason you want to install VNC Server on Linux, the instructions are layed out below.
Step 1 – Install VNC-Server with Yum
Do the following as root or using sudo:
yum install tigervnc-server |
Step 2 – Set the Password for the VNC User
Login with ssh as the user that will be using VNC and then set the password:
$ vncpasswd Password: Verify: |
Step 3 – Launch VNCServer for the First Time as the User That Will Use VNC to Create the Environment Files for That User
As the user that will be using VNC, launch the VNC Server to create the VNC Server files for the user.
$ vncserver xauth: creating new authority file /home/jeff/.XauthorityNew ‘myserver.mydomain.com:1 (mary)’ desktop is myserver.mydomain.com:1Creating default startup script /home/mary/.vnc/xstartup Starting applications specified in /home/mary/.vnc/xstartup Log file is /home/mary/.vnc/obelix.statenfamily.com:1.log |
Step 4 – Make a Backup of the Xstartup File and Edit it to Specify Gnome or Your Favorite Desktop
If you are hoping to use Gnome desktop, you will need to be sure that the Gnome desktop has been installed. On CentOS 6, this will install it for you:
# yum groupinstall “Desktop” |
Now let’s configure the user’s VNC environment to use Gnome:
$ cd $HOME/.vnc $ cp xstartup xstartup.orig |
Edit the $HOME/.vnc/xstartup file with your favorite Editor and change the last line from:
twm & |
to
gnome-session & |
Step 5 – Shutdown the VNCServer Session you Started in Step 3
$ vncserver -kill :1 Killing Xvnc process ID 3842 |
Step 6 – Setup VNCServer to Start at Boot Time
Get yourself to an ssh session and become the root user or use sudo and then:
Edit the /etc/sysconfig/vncservers file and change these default lines:
# VNCSERVERS=”2:myusername” # VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -localhost” |
to
VNCSERVERS=”1:mary” VNCSERVERARGS[1]=”-geometry 1024×768″ |
If you happen to be making VNC available to more than one user (remember to perform the steps above for each user) then do like this:
VNCSERVERS=”1:mary 2:user2″ VNCSERVERARGS[1]=”-geometry 1024×768″ VNCSERVERARGS[2]=”-geometry 1024×768″ |
Set to start at boot time:
# chkconfig vncserver on # chkconfig –list vncserver vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
Step 7 – Startup the VNCServer
# service vncserver start Starting VNC server: 1:mary New ‘obelix.statenfamily.com:1 (mary)’ desktop is myserver.mydomain.com:1Starting applications specified in /home/mary/.vnc/xstartup Log file is /home/mary/.vnc/myserver.mydomain.com:1.log[ OK ] |
Step 8 – Connect to VNC with Your Favorite VNC Client
There are lots of VNC clients that you can download and use. I have listed some below:
Windows | |
RealVNC | http://www.realvnc.com/download/viewer/ |
TightVNC | http://www.tightvnc.com/download.php |
Mac OSX | |
Chicken of the VNC | http://sourceforge.net/projects/chicken/ |
Launch the VNC Client and configure it to connect to your VNC Server.
To the right is an example of how I configured Chicken of the VNC to connect to my VNC Server.
Note that I listed the Display at 1 as was specified for this user in the /etc/sysconfig/vncservers file above.
Below is an image showing a connected VNC client to a VNC server. In this example, we are using the GNOME desktop as explained in the steps above.
That’s it. We setup The VNC Server and can now connect to it.
Latest posts by Jeff Staten (see all)
- Configure Your HP Procurve Switch with SNTP - May 5, 2015
- Configuring HP Procurve 2920 Switches - May 1, 2015
- Troubleshooting Sendmail - November 28, 2014