http://innorevinno.blogspot.com/. Diberdayakan oleh Blogger.
RSS

install VNC server on an Ubuntu PC and remote connect to it from a Windows PC

On the Ubuntu PC


The Ubuntu 9.10 PC shall hereafter be referred to as the SERVER.

First of all, permit remote desktop on the SERVER:From the menubar, select System | Preferences | Remote Desktop
  1. Under Sharing:
  1. Check Allow other users to view your desktop
  1. Check Allow other users to control your desktop
  1. Under Security:
  1. Select Require the user to enter this password
  1. and enter a password.
  1. Under Notification area:
  1. Select Only display an icon where there is somebody connected.
  1. Make a note of the network address and name of the SERVER as displayed in the Remote Desktop Preferences.
  1. Now ensure the required applications are installed:
  1. From the menubar, select System | Administration | Synaptic Package Manager
  1. In the quick search box, type vnc
  1. For each of the following four packages, right-click on them and select Mark for Installation
  1. vnc4server
  1. vnc4-common
  1. vinagre
  1. vino
  1. In the quick search box, type xinetd and install as described above.
  1. Finally, select Apply on the menubar to complete the installation.
  1. Now lets complete the VNC server install and configuration.
  1. Open up a command terminal:
  1. Run vncpasswd and enter the password that will be required by the client when attempting to connect to the SERVER
  1. vncpasswd
  1. Run the vncserver on display number 1 in order to generate the configuration files that we will subsequently customize.
  1. vncserver :1
  1. If you were to connect via remote desktop from a client at this point, the resolution would be wrong and the screen would be plain grey. Do not worry, we will fix that now. First, kill the vncserver process by issuing the command:
  1. vncserver -kill :1
  1. Edit the xstartup file in the folder .vnc (make a backup of the file first)
  1. gedit ~/.vnc/xstartup
  1. Ensure the file has the contents as follows:
unset SESSION_MANAGERsh /etc/X11/xinit/xinitrc
  1. Finally, to run the vnc server on the SERVER (on display 1), issue the command:
  1. vncserver :1 -depth 16 -geometry 1028x1024
On the Windows PC
  1. Download and install the VNC viewer of your cloice. I am using the free open sourceUltraVNC viewer.
  1. Note: UltraVNC is highly customizable.
  1. Run vncviewer.exe
  1. Enter in the network address of the SERVER pc (as recorded in step 1) immediately followed by a colon : and the display number. The following is an example of the format:
  1. Under Quick Options, select Auto.
  1. When prompted, enter the password specified in step 3.1
  1. Well Done! You are now connected over remote desktop to the Ubuntu PC from your Windows PC.
How to configure the VNC server to run at bootup on the Ubuntu PC.
  1. Open up a terminal and login as root
  1. sudo -i
  1. Run all the commands outlined in step 3 (for the Ubuntu PC) as root.
  1. Create a new file in /etc/init.d called vncserver and ensure it has the following contents:
  1. Note: Change the username (and optionally the other parameters) according to your circumstances.
### BEGIN INIT INFO# Provides: vncserver# Required-Start: networking# Default-Start: S# Default-Stop: 0 6### END INIT INFOPATH="$PATH:/usr/X11R6/bin/"# The Username:Group that will run VNCexport USER="YOUR_USERNAME"#${RUNAS}# The display that VNC will useDISPLAY="1"# Color depth (between 8 and 32)DEPTH="16"# The Desktop geometry to use.#GEOMETRY="<WIDTH>x<HEIGHT>"#GEOMETRY="800x600"#GEOMETRY="1024x768"GEOMETRY="1280x1024"# The name that the VNC Desktop will have.NAME="your-vnc-server"OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}". /lib/lsb/init-functionscase "$1" instart)su ${USER} -c "/usr/bin/vncserver ${OPTIONS}";;stop)su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}";;restart)$0 stop$0 start;;esacexit 0
  1. Make the above script executable:
  1. sudo chmod +x /etc/init.d/vncserver
  1. Make this script into a system service by adding this script to the runtime scripts invoked at bootup time.
  1. sudo update-rc.d vncserver defaults
  1. To start the service without rebooting the SERVER:
  1. sudo /etc/init.d/vncserver start
  1. If you made a mistake/typo in the script, you can undo the creation of the system-wide service (step 5) by running the command:
  1. sudo update-rc.d -f vncserver remove
    You may then correct your mistake and then repeat steps 5 and 6.
  1. Well done! You may now connect to your Ubuntu PC SERVER via remote desktop by simply powering on the SERVER and giving it enough time to bootup and run all of its system-wide services.
#!/bin/sh The Windows PC shall hereafter be referred to as the CLIENT.111.222.333.444:1 In practice, you will not want to logon to the SERVER just to initiate the VNC server. Moreover, you may not even have a monitor for your Ubuntu Server, because you may be using the monitor as a dual screen for your primary desktop, as in my case. :) These instructions have been referenced from here. To that end I will now explain how to ensure the VNC server is initialised at bootup time (simply by switching on the SERVER). All of the following steps will required you to be logged in as root.#!/bin/sh -e

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar: