Skip to content

Instantly share code, notes, and snippets.

@chaithyagr
Last active March 17, 2020 14:37
Show Gist options
  • Save chaithyagr/40b1b970d5d67e763e00c67182d463fb to your computer and use it in GitHub Desktop.
Save chaithyagr/40b1b970d5d67e763e00c67182d463fb to your computer and use it in GitHub Desktop.
Creating VNC Server

What is VNC?

VNC stands for Virtual Network controller, and it can be used to setup a remote desktop access.

How does VNC work?

There are 2 important parts of VNC: vncserver and vncviewer. vncserver must be setup on the remote desktop that you want to access. Once the vncserver is setup, you can use any vncviewer to connect. I would recoomend using RealVNC Viewer : https://www.realvnc.com/en/connect/download/viewer/

Setup on Remote desktop:

The following things need to be setup on remote desktop:

sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal gnome-core
sudo apt-get install vnc4server

Make a copy of vncserver script for backup: sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp

Update vnserver script to ensure we start gnome-panel:

sudo vim /usr/bin/vncserver

Find this line "exec /etc/X11/xinit/xinitrcnn". and add these lines like below "exec /etc/X11/xinit/xinitrcnn".

       "gnome-panel &\n".
       "nautilus &\n".
       "gnome-terminal &\n".
       "vncconfig -iconic &\n".

Start vncserver:

To start a VNC, please use the following, you can use a different geometry based on your local machine desktop:

vncserver -geometry 1920x1080

Viewer setup

Download VNC Viewer. Connect to desktop as machine-id.intra.cea.fr:

FAQ

Can I close the viewer? Will it stop my runs and processes?

You can peacefully close the viewer, the server is still running on your remote machine and all your runs are taking place smoothly, sont worry :P!

I think my server is bad, I get gray screen and an x mark as a pointer.

Ensure that you have all the rights needed to run gnome-terminal through ssh. Ideally you should not get any dbus launch errors or warnings. Also, ensure that your changes to vncserver script are right, and also that all the base stuff are installed. Sometimes, the issue could be something more intricate, do not hesitate to contact me or use stackoverflow (even I use that only after all :P)

I have created like 10 servers now, how do I stop this?

Please do ensure that you DO NOT create a lot of servers. If anything goes wrong, please kill the server with:

vncserver -kill <dispay-id>

With this you can ensure to use a single server running on your machine that is easy to track.

For more details, you can refer here: https://hackernoon.com/installation-of-vnc-server-on-ubuntu-1cf035370bd3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment