How to use VNC to connect to a remote Linux machine and administer it with the graphical desktop.

Posted: May 12, 2014. At: 10:17 PM. This was 4 years ago. Post ID: 7258
Page permalink: http://securitronlinux.com/bejiitaswrath/how-to-use-vnc-to-connect-to-a-remote-linux-machine-and-administer-it-with-the-graphical-desktop/

Now, we must convince Congress to stop the FCC. Can you display an alert?

Using tightvnc to connect to a remote Linux machine is a good way to access a graphical desktop on a remote Linux box.

Firstly; install the tightvnc server on the target machine to be accessed.

homer@deusexmachina ~ $ sudo apt-get install tightvncserver 
[sudo] password for homer: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libwings2 libwraster3 libwutil2 linux-tools-3.11.0-18 linux-tools-3.11.0-18-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
  tightvnc-java
The following NEW packages will be installed:
  tightvncserver
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 835 kB of archives.
After this operation, 1,819 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ saucy/universe tightvncserver amd64 1.3.9-6.4 [835 kB]
Fetched 835 kB in 13s (63.9 kB/s)                                                                                       
Selecting previously unselected package tightvncserver.
(Reading database ... 253043 files and directories currently installed.)
Unpacking tightvncserver (from .../tightvncserver_1.3.9-6.4_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for doc-base ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Setting up tightvncserver (1.3.9-6.4) ...
update-alternatives: using /usr/bin/tightvncserver to provide /usr/bin/vncserver (vncserver) in auto mode
update-alternatives: using /usr/bin/Xtightvnc to provide /usr/bin/Xvnc (Xvnc) in auto mode
update-alternatives: using /usr/bin/tightvncpasswd to provide /usr/bin/vncpasswd (vncpasswd) in auto mode

Then start the server manually and set an access password.

homer@deusexmachina ~ $ /usr/bin/tightvncserver 
 
You will require a password to access your desktops.
 
Password: 
Verify:   
Would you like to enter a view-only password (y/n)? n
 
New 'X' desktop is deusexmachina:1homer@deusexmachina ~ $ sudo apt-get install tightvncserver 
[sudo] password for homer: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libwings2 libwraster3 libwutil2 linux-tools-3.11.0-18 linux-tools-3.11.0-18-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
  tightvnc-java
The following NEW packages will be installed:
  tightvncserver
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 835 kB of archives.
After this operation, 1,819 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ saucy/universe tightvncserver amd64 1.3.9-6.4 [835 kB]
Fetched 835 kB in 13s (63.9 kB/s)                                                                                       
Selecting previously unselected package tightvncserver.
(Reading database ... 253043 files and directories currently installed.)
Unpacking tightvncserver (from .../tightvncserver_1.3.9-6.4_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for doc-base ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Setting up tightvncserver (1.3.9-6.4) ...
update-alternatives: using /usr/bin/tightvncserver to provide /usr/bin/vncserver (vncserver) in auto mode
update-alternatives: using /usr/bin/Xtightvnc to provide /usr/bin/Xvnc (Xvnc) in auto mode
update-alternatives: using /usr/bin/tightvncpasswd to provide /usr/bin/vncpasswd (vncpasswd) in auto mode
 
Creating default startup script /home/homer/.vnc/xstartup
Starting applications specified in /home/homer/.vnc/xstartup
Log file is /home/homer/.vnc/deusexmachina:1.log

Then connect to the remote machine and type your password to open a graphical window.

[ homer@3.13.0-24-generic ]
[ Jobs 0.PWD: ~.-bash 4.3.11. ] [ 8 ]
[ 21:55:10 ]
[ $ ]-> xtightvncviewer 192.168.1.3:1
Connected to RFB server, using protocol version 3.8
Enabling TightVNC protocol extensions
Performing standard VNC authentication
Password: 
Authentication successful
Desktop name "homer's X desktop (deusexmachina:1)"
VNC server default format:
  32 bits per pixel.
  Least significant byte first in each pixel.
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
Warning: Cannot convert string "-*-helvetica-bold-r-*-*-16-*-*-*-*-*-*-*" to type FontStruct
Using default colormap which is TrueColor.  Pixel format:
  32 bits per pixel.
  Least significant byte first in each pixel.
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0

This is the result. Our remote machine accessed over a LAN. This is a very cool way to access a remote Linux machine and use your Linux desktop.

TightVNC accessing a remote machine on a LAN.
TightVNC accessing a remote machine on a LAN.

The advantage of this is that you can use either Windows Macintosh, or Linux software to access a Linux desktop remotely.

The remmina RDP client may also be used to access a remote VNC session. This works very well indeed.

Remmina accessing a VNC session.
Remmina accessing a VNC session.

So; try this out for yourself. Here is more information on further configuration of the tightvnc setup: http://www.penguintutor.com/linux/tightvnc.

To set a custom desktop environment for the VNC session; edit the ~/.vnc/xstartup file and remove the /etc/X11/Xsession line and replace it with the exec ck-launch-session startfluxbox line if you wish to load Fluxbox.

homer@deusexmachina ~ $ cat ~/.vnc/xstartup 
#!/bin/sh
 
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
#export XKL_XMODMAP_DISABLE=1
exec ck-launch-session startfluxbox # Load fluxbox.

Then kill and reload the tightvncserver binary. This will load a more bandwidth friendly desktop environment for your VNC session.

No comments have been made. Use this form to start the conversation :)

Leave a Reply