Log in to a Home Server with VNC

I have a home server which acts a samba wins server, a DNS server and a Ubuntu Apt-Mirror. I have LMDE installed but I no longer have an attached monitor and keyboard. Normally I can SSH in to my server to make changes, but sometimes it’s more convenient to log in to an X-window session. One of the easiest ways to accomplish that is with VNC. There are lots of ways to set that up, heres one way.

VNC server setup on your home server:

LightDM, the default Ubuntu display manager, supports a VNC server out of the box. It works quite well with the vinagre VNC client available in the Ubuntu repositories.

So, to begin the setup process start by setting up the VNC password. So open a terminal and log in to your server. Note I’m assuming here that your server has no monitor so you’ll need to log in via ssh.

ssh yourusername@yourserveripaddress

Then create your VNC password using:

sudo x11vnc -storepasswd /etc/x11vnc.pass

Then make it readable using:

sudo chmod 660 /etc/x11vnc.pass

Next you need to test your server. Start the server from the terminal using:

/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900

The VNC server will now start. It should prompt for a password when you log in from the client machine.

VNC client setup on your “remote” desktop.

Note: by remote, I mean some desktop or laptop machine on your local network other than the home server. All that’s required on that machine is a VNC client. In this case I’ll use Vinagre, but there are mutriple others. To install the client, open a terminal on the “remote machine” and:

sudo apt-get install vinagre.

After it’s installed It’s time to test the server. So, start vinagre either from Dash or whatever launcher you prefer (I use Cardapio).

Once vinagre runs, press the Connect button. At that point a window should open. See below:

Screenshot from 2013-06-07 20:56:35

Make sure the Protocol is set to VNC, then type the IP address of your home server into the Host field and press Connect. The VNC server should now prompt for your password, the one you created earlier, not your user password. After a few moments the X window should open, probably to you login screen. If so, everything is working and it’s time to set your server to run teh VNC server at startup.

Running the VNC Server at startup.

To run VNC server at startup, open up a terminal create a script:

sudo nano /etc/x11vnc.conf

and enter the following:

#!
/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900

Then save and exit.

Next, still in the terminal:

sudo chmod 770 /etc/x11vnc.conf

Finally to run your script at startup:

sudo nano /etc/init.d/rc.local

then add the following line at the end of the file

/etc/x11vnc.conf &

save and exit.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: