<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Free Associations &#187; xinetd</title>
	<atom:link href="http://www.scotttyee.com/blog/tag/xinetd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scotttyee.com/blog</link>
	<description>Ramblings of a Technology Handyman.</description>
	<lastBuildDate>Mon, 25 Jul 2011 20:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Linux: Headless Ubuntu with VNC</title>
		<link>http://www.scotttyee.com/blog/2009/12/09/linux-headless-ubuntu-with-vnc/</link>
		<comments>http://www.scotttyee.com/blog/2009/12/09/linux-headless-ubuntu-with-vnc/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 01:30:21 +0000</pubDate>
		<dc:creator>yeehaw</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Technology, Science and Engineering]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[instructions]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VNC]]></category>
		<category><![CDATA[xinetd]]></category>

		<guid isPermaLink="false">http://scotttyee.com/blog/?p=158</guid>
		<description><![CDATA[First a little background a few years ago I decided to take an older PC which I have modified to be used as a network attached storage (NAS) and internal web server. I have configured it in the past as a RAID 1 setup with Windows Small Business Server. Recently I have decided to enter [...]]]></description>
			<content:encoded><![CDATA[<p>First a little background a few years ago I decided to take an older PC which I have modified to be used as a network attached storage (NAS) and internal web server.  I have configured it in the past as a RAID 1 setup with Windows Small Business Server.  Recently I have decided to enter the world of Linux and this box will be the first attempt at making a server.  I am definitely a n00b in the world of Linux but eager to learn.  For this post I will go over how I configured Ubuntu Linux 9.10 for VNC over SSH while using the GDM for graphically logging in to the server.</p>
<p><strong>Need:</strong> Since I am new to Linux and still feel more comfortable with a graphical user interface (GUI) it is preferable to be able to use a GUI to administer the server as I did using Windows and their Remote Desktop Connection (RDC) service.  My primary needs are to have a headless server that can be maintained via VNC over a SSL secure connection (headless system is a computer that does not have a keyboard, monitor or mouse).</p>
<p><strong>Current configuration:</strong></p>
<ul>
<li>x86 system with system hard drive and a RAID 1 storage array</li>
<li>Running <a href="http://www.ubuntu.com/">Ubuntu</a> <a href="http://releases.ubuntu.com/">Server 9.10</a> for 32-bit x86</li>
</ul>
<p><strong>Software:</strong></p>
<p>After some research on the wonderful resources and forums that the Linux community has, I determined what specific software that will be needed to facilitate this server setup. In order to complete this task the following four packages will be installed:</p>
<ul>
<li>Desktop environment: Ubuntu GNOME</li>
<li>SSH Server</li>
<li>xinetd</li>
<li>VNC Server</li>
</ul>
<p>To operate Virtual Network Computing (<a href="http://.wikipedia.org/wiki/VNC" target="_blank" title="From Wikipedia the definition of: VNC" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >VNC</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup>) you will need to install some type of desktop environment, for the purposes of this example, the standard GNOME interface for Ubuntu if you prefer the KDE or XFCE they are also available for Ubuntu.  You can look up their install procedures here:</p>
<ul>
<li>KDE (https://help.ubuntu.com/community/InstallingKDE)
<ul>
<li><em>Command Line:</em><span style="color: #0000ff;"> <span style="color: #000000;">&gt;</span> sudo apt-get install kubuntu-desktop</span></li>
</ul>
</li>
<li>Xfce (https://help.ubuntu.com/community/InstallingXubuntu)
<ul>
<li><em>Command Line: &gt; </em><span style="color: #0000ff;">sudo apt-get install xubuntu-desktop</span></li>
</ul>
</li>
</ul>
<p>To enable a secure shell connection for the VNC I installed Open SSH Server for secure port forwarding.</p>
<ul>
<li>For more basic description of SSH: <a href="http://.wikipedia.org/wiki/Secure_Shell" target="_blank" title="From Wikipedia the definition of: Secure Shell" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >Secure Shell</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup></li>
<li>More information on VNC over SSH, <a href="https://help.ubuntu.com/community/VNCOverSSH">https://help.ubuntu.com/community/VNCOverSSH</a></li>
</ul>
<p>Installation of xinetd will allow for your VNC services to start on startup of your server, proper configuration of VNC for xinetd will be explained later in this tutorial.  For more basic description of xinetd: <a href="http://.wikipedia.org/wiki/xinetd" target="_blank" title="From Wikipedia the definition of: xinetd" style="padding-bottom: 2px; border-bottom: 1px dotted #DD0000" >xinetd</a><sup style="font-family: Georgia, Times New Roman, Serif; font-weight: bold; color: #AAAAAA" ><em>W</em></sup></p>
<p>Finally installation of the VNC Server, for the purposes of this demo we will be installing vnc4server.</p>
<p><strong>How to install the necessary software:</strong></p>
<p>V<em>ia the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo apt-get update </span> <span style="color: #008000;"># Update software packages to the most current available in their repositories (this will insure you will have the most up to date software packages from the approved repositories, this does not guarantee that you will have the newest version just the newest approved in their perspective repository.</span></p>
<p style="padding-left: 30px;">&gt;<span style="color: #0000ff;"> sudo apt-get upgrade</span> <span style="color: #008000;"># Upgrade current software to the newest from the updated repositories</span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo apt-get install ubuntu-desktop</span> <span style="color: #008000;"># Install the Desktop Environment</span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo apt-get install openssh-server</span> <span style="color: #008000;"># Install openSSH Server</span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo apt-get install xinetd </span> <span style="color: #008000;"># Install xinetd</span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo apt-get install vnc4server </span> <span style="color: #008000;"># Install VNC Server</span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo shutdown -r now</span> <span style="color: #008000;"># Shutdown and restart your system, the system should boot to the GUI</span></p>
<p>Upon reboot, you can access the command line for further configuration that is outlined below by going to: <em>Applications &gt; Accessories &gt; Terminal</em></p>
<p><strong>Configure the VNC Server:</strong></p>
<p>First we will run VNC and will set your VNC password, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt;<span style="color: #0000ff;"> vnc4server</span></p>
<p>The output will list your server name and display number &#8220;<span style="color: #800000;"><span style="color: #000000;">:</span>#&#8221;</span>, please note what number is after the colon, this will be used to shutdown the newly opened VNC session before we configure the VNC startup, now we will shutdown VNC server, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">vnc4server -kill </span><span style="color: #800000;"><span style="color: #0000ff;">:</span>#</span></p>
<p>Just in case we may need the default file we will backup the file <span style="color: #808080;">.vnc/startup</span>, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">cd ~.vnc/</span> <span style="color: #008000;"># Go to the correct directory</span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo cp startup startup.original </span> <span style="color: #008000;"># Copy startup as startup.original</span></p>
<p>Now we will edit the file .vnc/startup</p>
<p>Change the file to look like the following, use your preferred text editor (gedit, vi, etc.), <em>via the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo gedit startup</span> <span style="color: #008000;"># Open Gedit to edit the file .vnc/startup</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">#!/bin/sh</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;"># Uncomment the following two lines for normal desktop:</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">unset SESSION_MANAGER</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">exec /etc/X11/xinit/xinitrc</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">[ -x /etc/vnc/xstartup ] &amp;&amp; exec /etc/vnc/xstartup</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">[ -r $HOME/.Xresources ] &amp;&amp; xrdb $HOME/.Xresources</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">#xsetroot -solid grey</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">#vncconfig -iconic &amp;</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">#xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &amp;</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">#twm &amp;</span></p>
<p>We uncommented the previous file to allow execution of the X11 file xinitrc, and commented out some of the configuration that we will not need, now we will need to make this file executable, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo chmod 755 /etc/X11/xinit/xinitrc</span></p>
<p><em>References:</em></p>
<ul>
<li><a href="http://www.ehow.com/how_5089245_install-vnc-server-ubuntu.html">http://www.ehow.com/how_5089245_install-vnc-server-ubuntu.html</a></li>
<li><a href="http://www.movingtofreedom.org/2007/02/16/howto-remote-desktop-with-vnc-in-ubuntu-edgy-gnu-linux/">http://www.movingtofreedom.org/2007/02/16/howto-remote-desktop-with-vnc-in-ubuntu-edgy-gnu-linux/</a></li>
</ul>
<p><strong>Configuring xinetd:</strong></p>
<p>Create a file called Xvnc in <span style="color: #808080;">/etc/xinetd.d/Xvnc<span style="color: #000000;"> this file will be initialized to start your VNC service on startup of your computer</span></span>, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt;<span style="color: #0000ff;"> sudo gedit /etc/xinetd.d/Xvnc</span></p>
<p style="padding-left: 30px;"><em>Insert the following text in the file, remember to insert the correct number for the display number (<span style="color: #800000;">#</span>), usually the default ports for VNC start at 5900, where the port corresponds to the display number, i.e. display :0 &gt; 5900, display :1 &gt; 5901, etc:</em></p>
<p style="padding-left: 30px;"><span style="color: #940094;">service Xvnc</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">{</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">type = UNLISTED</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">disable = no</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">socket_type = stream</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">protocol = tcp</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">wait = yes</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">user = root</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">server = /usr/bin/Xvnc</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">server_args = -inetd :1 -query localhost -geometry 1024×768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd -extension XFIXES</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">port = 590</span><span style="color: #800000;">#</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">}</span></p>
<p><strong><em><span style="color: #888888;">Update, Note: <span style="color: #000000;"><span style="font-style: normal; font-weight: normal;">Depending on your setup, the &#8216;server_args&#8217; statement may need to be changed for the passwordFile location, on my setup the root file is located at /root/.vncpasswd, Derek thankfully pointed out that it also could also be located at /root/.vnc/passwd.  So please verify where your password file is located and update the Xvnc file accordingly.</span></span></span></em></strong></p>
<p>We will need to restart xinetd, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo /etc/init.d/xinetd restart</span></p>
<p><strong>GDM and XDMCP:</strong></p>
<p>Next we will configure GDM and XDMCP in Ubuntu 9.10 (Thanks to Mark for figuring this out, <a href="http://www.peppertop.com/blog/?p=690">http://www.peppertop.com/blog/?p=690</a>)</p>
<p>For Ubuntu 9.10 it appears that there has been significant changes to GDM and XDMCP server.</p>
<p>Copy the sample configuration file, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo cp /usr/share/doc/gdm/examples/custom.conf /etc/gdm/</span></p>
<p>Edit the file and enable the XDMCP, this will allow a login screen for your VNC desktop environment, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo gedit /etc/gdm/custom.conf</span></p>
<p style="padding-left: 30px;">Find the “[xdmcp]” heading and add “Enable=true” below.</p>
<p style="padding-left: 30px;">Sample file:</p>
<p style="padding-left: 30px;"><span style="color: #940094;"># GDM configuration storage</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">[xdmcp]</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">Enable=true</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">[chooser]</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">[security]</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">[debug]</span></p>
<p><em>Save and close Gedit</em></p>
<p>For improved security we will disable how the Ubuntu 9.10 uses the newer GDM because by default they list the users at the login screen, <em>to disable this at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo -u gdm gconftool-2 -t bool -s /apps/gdm/simple-greeter/disable_user_list true</span></p>
<p>Reference: <a href="http://ubuntuforums.org/showthread.php?t=1344205">http://ubuntuforums.org/showthread.php?t=1344205</a></p>
<p><strong>Configuring X11 to Operate Without a Monitor:</strong></p>
<p>We will need to configure X11 to operate without a monitor, otherwise after you configure your server and disconnect the monitor the VNC will not function properly due to missing hardware.</p>
<p>Create a file called <span style="color: #888888;">/etc/X11/xorg.conf </span>and paste the following,<em> at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo gedit /etc/X11/xorg.conf</span></p>
<p style="padding-left: 30px;"><em>Insert the following text in the file:</em></p>
<p style="padding-left: 30px;"><span style="color: #940094;">Section “Device”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">Identifier “VNC Device”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">Driver “vesa”</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">EndSection</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">Section “Screen”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">Identifier “VNC Screen”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">Device “VNC Device”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">Monitor “VNC Monitor”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">SubSection “Display”</span></p>
<p style="padding-left: 90px;"><span style="color: #940094;">Modes “1280×1024″</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">EndSubSection</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">EndSection</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">Section “Monitor”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">Identifier “VNC Monitor”</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">HorizSync 30-70</span></p>
<p style="padding-left: 60px;"><span style="color: #940094;">VertRefresh 50-75</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">EndSection</span></p>
<p><em>Reference:</em> <a href="http://ubuntuforums.org/showthread.php?t=1297815">http://ubuntuforums.org/showthread.php?t=1297815</a></p>
<p>Hopefully with a configured xinetd, VNC, XDMCP and installed SSH you can restart your machine and try to VNC into your machine.</p>
<p><strong>VNC Clients:</strong></p>
<p><strong><em>Mac:</em></strong> Jolly Fast VNC, this VNC viewer allows for SSH configuration</p>
<ul>
<li>Website: <a href="ttp://www.jinx.de/JollysFastVNC.html">http://www.jinx.de/JollysFastVNC.html</a></li>
<li>Download: <a href="http://www.jinx.de/JollysFastVNC_files/JollysFastVNC.0.98.50.%28928701%29.dmg">http://www.jinx.de/JollysFastVNC_files/JollysFastVNC.0.98.50.%28928701%29.dmg</a></li>
<li>SSH Configuration: -L 590<span style="color: #800000;">#</span>:localhost:590<span style="color: #800000;">#</span> username@servername.local</li>
</ul>
<p><strong><em>Windows:</em></strong> Putty, this VNC viewer allows for SSH configuration</p>
<ul>
<li>Website: <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">http://www.chiark.greenend.org.uk/~sgtatham/putty/</a></li>
<li>Download: <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html</a></li>
<li>SSH Configuration: -L 590<span style="color: #800000;">#</span>:localhost:590<span style="color: #800000;">#</span> username@servername.local</li>
<li>Tutorial for PuTTY: <a href="http://home.chattanooga.net/~john/Putty-Tunnel/putty-tunnel.html">http://home.chattanooga.net/~john/Putty-Tunnel/putty-tunnel.html</a></li>
</ul>
<p><strong><em>Linux: </em><span style="font-weight: normal;">Vinagre</span></strong></p>
<ul>
<li>Website: <a href="http://projects.gnome.org/vinagre/">http://projects.gnome.org/vinagre/</a></li>
</ul>
<p>Ubuntu and other Linux distributions usually have a VNC viewer installed, for this example we will use the preinstalled Remote Desktop Viewer on Ubuntu.  We will create a shell script to both create a SSH connection to your headless server and open the VNC viewer for you to select the server and login.</p>
<p>Example script for using SSH and the built in Remote Desktop Viewer/VNC client on Ubuntu, <em>at the command line</em>:</p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo gedit /home/username/Desktop/VNCtoServer.sh </span> <span style="color: #008000;"># Create a new file for the shell script on your Desktop</span></p>
<p style="padding-left: 30px;"><em>Insert the following text in the file:</em></p>
<p style="padding-left: 30px;"><span style="color: #940094;">#! /bin/bash</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;"># Open Vinagre VNC Viewer and Open SSH Tunnel to Server for VNC</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">vinagre &amp; ssh -L 590<span style="color: #800000;">#</span>:localhost:590<span style="color: #800000;">#</span> username@servername.local cat &#8211; &amp;</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;">exit 0</span></p>
<p style="padding-left: 30px;"><span style="color: #940094;"><em><span style="color: #000000;">Save file and close Gedit</span></em></span></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo chmod 775 /home/username/Desktop/VNCtoServer.sh        <span style="color: #008000;"># This will make the shell script file executable</span></span></p>
<p><span style="color: #0000ff;"><span style="color: #000000;">You can now run this script every time you want to VNC into your server. </span></span></p>
<p><span style="color: #0000ff;"><span style="color: #008000;"><span style="color: #000000;"><strong>Linux: </strong>TightVNC</span></span></span></p>
<ul>
<li><span style="color: #0000ff;"><span style="color: #008000;"><span style="color: #000000;">Website: </span></span></span><a href="http://www.tightvnc.com/">http://www.tightvnc.com/</a></li>
<li>Tutorial for TightVNC and SSH: <a href="http://ubuntu-tutorials.com/2007/06/12/vnc-over-ssh-securing-the-remote-desktop/">http://ubuntu-tutorials.com/2007/06/12/vnc-over-ssh-securing-the-remote-desktop/</a></li>
</ul>
<p>To install, <em>at the command line:</em></p>
<p style="padding-left: 30px;">&gt; <span style="color: #0000ff;">sudo apt-get install xtightvncviewer</span><em> </em><span style="color: #008000;"> # Install tightvnc client</span></p>
<p>For convenience I created a launcher for TightVNC to load with the SSH client, for the Command Field for the launcher:<em> </em><span style="color: #0000ff;">vncviewer -via username@servername.local localhost:590</span><span style="color: #800000;">#</span></p>
<p><span style="color: #0000ff;"><span style="color: #000000;">I hope this helps, Enjoy!</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scotttyee.com/blog/2009/12/09/linux-headless-ubuntu-with-vnc/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

