<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://morison.biz/technotes/feeds/rss.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/" 
	xmlns:dc="http://purl.org/dc/elements/1.1/" 
	xmlns:icbm="http://postneo.com/icbm/" 
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 
	xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" 
	xmlns:wfw="http://wellformedweb.org/CommentAPI/" >

<channel>
	<title>Rod Morison Software</title>
	<link>http://morison.biz/</link>
	<description>Software how-tos, ideas, opinion and discussion on desktop, server, and web application development

&lt;form action=&quot;http://morison.biz/technotes/search.php&quot; method=&quot;GET&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;search&quot; size=&quot;10&quot; maxlength=&quot;128&quot; /&gt;»&lt;/form&gt;</description>
	<language>en</language>
	<copyright>2006-2008, Rod Morison Software</copyright>
	<managingEditor>technotes@morison.biz</managingEditor>
	<webMaster>technotes@morison.biz</webMaster>
	<lastBuildDate>Sun, 01 Aug 2010 09:15:00 GMT</lastBuildDate>
	<generator>Yet Another Community System</generator>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>70</ttl>

	<item>
		<title>Won't get hacked again?</title>
		<link>http://morison.biz/technotes/articles/70</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/70</guid>
		<description>See http://news.bbc.co.uk/2/hi/technology/8550219.stm</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">See <a href="http://news.bbc.co.uk/2/hi/technology/8550219.stm" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://news.bbc.co.uk/2/hi/technology/8550219.stm</a></div>
UPDATE: <br />
<br />
<pre>RedirectMatch 301 ^/technotes/users/edit.* /technotes/articles/69</pre><br />
<br />
is keeping the rats at bay for now.</body>
		<dc:creator>rod</dc:creator>
		<category>//</category>
		<pubDate>Thu, 11 Mar 2010 06:34:47 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/70#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/70</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/70</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:70</trackback:ping>
	</item>

	<item>
		<title>Sorry...</title>
		<link>http://morison.biz/technotes/articles/69</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/69</guid>
		<description>...Due to hacking as described in http://news.bbc.co.uk/2/hi/technology/8550219.stm</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">...Due to hacking as described in <a href="http://news.bbc.co.uk/2/hi/technology/8550219.stm" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://news.bbc.co.uk/2/hi/technology/8550219.stm</a></div>
this url has been blocked.</body>
		<dc:creator>rod</dc:creator>
		<category>Misc</category>
		<pubDate>Mon, 08 Mar 2010 08:34:50 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/69#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/69</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/69</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:69</trackback:ping>
	</item>

	<item>
		<title>Hacked!</title>
		<link>http://morison.biz/technotes/articles/68</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/68</guid>
		<description>See http://news.bbc.co.uk/2/hi/technology/8550219.stm</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">See <a href="http://news.bbc.co.uk/2/hi/technology/8550219.stm" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://news.bbc.co.uk/2/hi/technology/8550219.stm</a></div>
I've been nursing the yacs PHP based site *far* too long. Time to move it to some newer-tech, and definitely not PHP.<br />
<br />
Only question is what to do with all this old content and urls?</body>
		<dc:creator>rod</dc:creator>
		<category>//</category>
		<pubDate>Mon, 08 Mar 2010 07:24:44 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/68#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/68</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/68</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:68</trackback:ping>
	</item>

	<item>
		<title>Job inquiry, opening for Solutions Architect in Burbank</title>
		<link>http://morison.biz/technotes/articles/67</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/67</guid>
		<description>I would like to see if are interested in a Solutions Architect job opening with Rovi in our Burbank location.  Please let me know if your interested, or feel free to forward this to others who might be.  Thanks!



Summary:



The Solutions Architect will be responsible for architecting and designing comprehensive solutions that meet with our customers’ requirements for Rovi’s Passport Interactive Programming Guide (IPG).  Working side-by-side with prospective and existing customers, the Solutions Architect plays a key role in the successful selection, purchase, installation and maintenance of IPG solutions.  In addition to demonstrated strengths in systems assessment ... more  </description>
		<body xmlns="http://www.w3.org/1999/xhtml">I would like to see if are interested in a Solutions Architect job opening with Rovi in our Burbank location.  Please let me know if your interested, or feel free to forward this to others who might be.  Thanks!<br />
<br />
Summary:<br />
<br />
The Solutions Architect will be responsible for architecting and designing comprehensive solutions that meet with our customers’ requirements for Rovi’s Passport Interactive Programming Guide (IPG).  Working side-by-side with prospective and existing customers, the Solutions Architect plays a key role in the successful selection, purchase, installation and maintenance of IPG solutions.  In addition to demonstrated strengths in systems assessment and design, the Solutions Architect must also possess strong interpersonal skills and be able to relate to a wide range of technical and business individuals, including managers and executives within customer environments.
 
 
Responsibilities:<br />
<br />
•	Develop and present IPG solution architectures internally and to customers and partners 
•	Perform impact and system analyses based on customer requirements.
•	Support proposal development.
•	Support the development of test architectures and technology validation strategies.
•	Develop consensus and working relationships with technical teams from other external and internal cross-functional teams to ensure coordination and scalability.
•	Collaborate with other technical teams in the exchange and transfer of technical knowledge and in the development and evolution of architecture standards, guidelines, reference architecture, and the Passport Product Roadmap. 
•	Build and deliver technical and business blueprints that map to customers’ business goals and requirements.
•	Partner across internal and external functional teams to gather facts, develop and deliver cohesive solutions that meet customer requirements.
•	Other relevant duties as assigned.<br />
<br />
Qualifications &amp; Experience:<br />
<br />
•	MUST have experience with digital video systems including architectures and equipment such as digital video set top boxes, head-ends, conditional access (security) and digital video servers.  
•	Must have experience with  Motorola and Cisco headends
•	10+ years of progressive technical and leadership experience in network engineering and design roles in the service provider or systems operator space.
•	Demonstrated knowledge of object oriented analysis and design.
•	Demonstrated knowledge of and experience with systems integration methods and technologies. 
•	Demonstrated experience in performing complex analysis, consulting and providing recommendations to customers. 
•	Demonstrated knowledge of and experience with best practices of quality management.
•	8+ years software development experience in a Unix-based environment
•	Expertise in C/C++ object oriented multithreading
•	Experience developing, analyzing, and implementing complex algorithms 
•	Experience in CORBA
•	Experience in PERL
•	Experience in SUN RPC experience required
•	BS or MS degree in Computer Science or related field,  or an equivalent combination of education, training, and work experience
 
Personal:<br />
<br />
•	Able to prepare specifications and reports, deliver oral presentations, and explain complex technical concepts in simple terms.
•	Possess strong leadership skills and the ability to providing direction to cross-functional teams responsible for resolution of complex technical challenges. 
•	Good knowledge of project management concepts. 
•	Able to quickly learn, assess, adapt and respond effectively and appropriately to changing environments.
•	Enjoys the challenges encountered in selling complex technology in a competitive environment.
•	Customer focused - understands and appropriately responds to customers' business needs. 
•	Able to interface effectively and collaborate with clients, peers, and management to develop solutions and ensure stakeholder buy- in. 
•	Able to accurately analyze information and make sound decisions.  
•	Takes initiative and accountability for achieving results.
•	Strong sense of personal ethics and values.<br />
<br />
Eric Rydingsword
Employment Specialist
 
Rovi Corporation
 PH 408-764-5402 |  C 650-218-8600  |  FAX 408-567-1806 |  EMAIL <script type="text/javascript">document.write('<a href="' + 'mailto:Eric' + '.' + 'Rydingsword' + '@' + 'RoviCorp' + '.' + 'com' + '" class="email" title="Send a message">' + 'Send a message' + '</a>')</script><noscript><p>Please enable JavaScript to see this address</p></noscript>
<a href="http://www.rovicorp.com" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.rovicorp.com</a>
Rovi. The new name for Macrovision.</body>
		<dc:creator>Eric Rydingsword</dc:creator>
		<category>Queries</category>
		<pubDate>Fri, 05 Feb 2010 04:33:58 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/67#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/67</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/67</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:67</trackback:ping>
	</item>

	<item>
		<title>Boost C++ Dev Setup</title>
		<link>http://morison.biz/technotes/articles/50</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/50</guid>
		<description>Get Python

I use boost.python, so python must be installed before building boost. No need to build from source, just get the Windows installer from http://python.org/. I'm using python 2.6 right now, haven't tried the 3.X series yet. Add C:\Python26 to your Windows PATH environment variable. (You can do it when you modify that below.)
Boost Build

The boost windows docs has all the instructions you really need to build boost. This guide only adapts that to my local dev conventions
 Get the boost source from http://sourceforge.net/projects/boost/files/
 Also, get the Windows bjam .exe, currently ... more  </description>
		<body xmlns="http://www.w3.org/1999/xhtml"><h2 id="title_3" >Get Python</h2>
I use boost.python, so python must be installed before building boost. No need to build from source, just get the Windows installer from <a href="http://python.org/." title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://python.org/.</a> I'm using python 2.6 right now, haven't tried the 3.X series yet. Add C:\Python26 to your Windows PATH environment variable. (You can do it when you modify that below.)
<h2 id="title_4" >Boost Build</h2>
The <a href="http://www.boost.org/doc/libs/1_39_0/more/getting_started/windows.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">boost windows docs</a> has all the instructions you really need to build boost. This guide only adapts that to my local dev conventions
<ul><li> Get the boost source from http://sourceforge.net/projects/boost/files/
</li><li> Also, get the Windows bjam .exe, currently rev'd at: http://sourceforge.net/projects/boost/files/boost-jam/boost-jam-3.1.17-1-ntx86.zip/download
</li><li> Make your dev dirs. I use cygwin, you can easily translate to the Windows command shell. Unless you have tar, though, make sure you download the zip distro of boost. Also, I use the cygpath of "http://morison.biz/" instead of "http://morison.biz/cygdrive", i.e., I run <code>mount -s --change-cygdrive-prefix /</code>
<pre>cd "http://morison.biz/c/Documents and Settings/Rod/My Documents"<br/>mkdir -p Devel/local<br/>cd Devel/local<br/>mkdir bin lib src tmp<br/>cd src<br/>tar jxf ~/Downloads/boost_1_39_0.tar.bz2 <br/>cd ../bin<br/>unzip ~/Downloads/boost-jam-3.1.17-1-ntx86.zip <br/>mv boost-jam-3.1.17-1-ntx86/bjam.exe  .<br/>chmod +x bjam.exe<br/>rm -rf boost-jam-3.1.17-1-ntx86/</pre>
</li><li> Add the Devel/local/bin path to your Windows path variable (Control Panel->System, Advanced Tab, Environment Variables Button):<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/50/DevelLocalBinPath.png" alt="DevelLocalBinPath.png"  title=""http://morison.biz/></span></span>
</li><li> Start a Visual C++ command shell, i.e., menu to something like: <br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/50/StartVisualStudioSHell.png" alt="StartVisualStudioSHell.png"  title=""http://morison.biz/></span></span>
<pre>Setting environment for using Microsoft Visual Studio 2008 x86 tools.<br/>C:/Users/rod/KlickFu/Devel/local/src/boost_1_39_0>bjam --build-dir=../../tmp/boost --prefix=../.. --toolset=msvc --threading=multi --runtime-link=static  link=static debug release install</pre>
Actually, I'm currently building with...
<pre>C:Develboost_1_43_0>bjam --build-dir=../tmp --prefix=../boost --build-type=complete runtime-link=static --without-graph --without-graph_parallel --without-mpi --without-wave msvc install</pre></li></ul></body>
		<dc:creator>rod</dc:creator>
		<category>C++</category>
		<pubDate>Mon, 31 May 2010 14:29:36 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/50#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/50</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/50</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:50</trackback:ping>
	</item>

	<item>
		<title>Remount a readonly disk readwrite</title>
		<link>http://morison.biz/technotes/articles/65</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/65</guid>
		<description>Just a reminder</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Just a reminder</div>
mount -o remount,rw /dev/sda1 /</body>
		<dc:creator>rod</dc:creator>
		<category>Linux</category>
		<pubDate>Thu, 10 Dec 2009 06:59:54 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/65#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/65</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/65</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:65</trackback:ping>
	</item>

	<item>
		<title>How To Build a Vhosted Linux Development Server on Windows using VirtualBox</title>
		<link>http://morison.biz/technotes/articles/61</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/61</guid>
		<description>I've been doing a fair bit of PHP and Python on Linux recently. My favorite PHP editor, PhpEd is Windows only. However, I prefer to develop LAMP code on LAMP. Here's a solution: Linux on VirtualBox, networked to the host Windows OS</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">I've been doing a fair bit of PHP and Python on Linux recently. My favorite PHP editor, <a href="http://www.nusphere.com/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">PhpEd</a> is Windows only. However, I prefer to develop LAMP code on LAMP. Here's a solution: Linux on VirtualBox, networked to the host Windows OS.</div>
<p class="caution"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/caution.gif" width="10" height="10" alt="!!!" /> NOTE: The latest version of VirtualBox, 3.0.2 at this time, puts a few things in different places, particularly the VT-x/AMD-V and Nested Paging settings. Check the latest VirtualBox docs for more info</p><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Get and install <a href="http://www.virtualbox.org/wiki/Downloads" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">VirtualBox</a> for your system.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Get the install iso for your preferred Linux distro, in my case <a href="http://www.ubuntu.com/getubuntu/download" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Ubuntu</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Create a new virtual machine in VirtualBox, e.g., by clicking "New" and using the Virtual Machine Wizard <br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/NewVirtualMachine.png" alt="NewVirtualMachine.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Navigating the wizard is straightforward. Name your machine, set the OS type, etc. I configure for 768MB RAM and create a new 30 GB hard drive. If your DB or file storage needs for dev are large, up the disk as needed. The RAM is plenty for most dev LAMP servers unless you run big backend progs.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Once you've created the machine and disk, before booting the VM, go to the Settings dialog, General, Advance tab and turn on Nested Paging. VirtualBox will only use it if available, but if it is available, it greatly streamlines the memory interface between guest and host.<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/NestedPaging.png" alt="NestedPaging.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Now attach the boot/install iso you downloaded for your linux distro. Use the VirtualBox Media Manager to attach the iso, then mount it on your VM.<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/AttachIso.png" alt="AttachIso.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Next, go to the Network entry in Settings and enable Adapter 2, set Attached to: to Host-only Adapter and Name to VirtualBox Host-Only Ethernet Adapter. This adapter will be for Apache name and IP virtual hosts exposed on the host OS.<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/NetworkAdapter.png" alt="NetworkAdapter.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Finally (as far as the VM setup goes), setup a share to a folder on Windows. This will map to /var/www in the linux guest and be used there by Apache. Personally, I map a vhosts folder on windows to /var/www/vhosts on the Linux side, then put my domains under vhosts, i.e., /var/www/vhosts/mydevsite.com. (Looking ahead, you'll edit the files on the Windows side, but they will be served on the Linux side.)<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/SharedFolders.png" alt="SharedFolders.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Start the VM and install your Linux OS (not shown). I recommend updating your Linux with your distro's package manager. With Ubuntu Desktop, that's pretty trivial once you're installed and booted (it may pop up an update request before you even make it to the Update Manager menu):<br />
<br />
<span class="inline_image"><span class="large"><span><img src="http://morison.biz/technotes/images/article/61/UbuntuUpdateMenu.png" alt="UbuntuUpdateMenu.png"  title=""http://morison.biz/></span></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  You'll probably want the VBoxAdditions installed in your Linux guest. VBoxAdditions allows cut/paste between host/guest, seemless mouse operation, etc. First, be sure to eject any mounted CD or ISO in the guest OS. From the VirtualBox "Devices" menu outside the guest console select "Install Guest Additions...". That should mount a VBoxAdditions CD.  Run <code>sudo /cdrom/VBoxLinuxAdditions-x86.run</code> from a shell in the guest. (If you installed a 64bit AMD Linux, look for VBoxLinuxAdditions-amd64.run.) This script will require a reboot and may need to be re-run after certain kernel updates.<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/InstallVboxAdditions.png" alt="InstallVboxAdditions.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Finally, time to install the LAMP goods. From a shell in the Linux guest (again, for Ubuntu packages):
<pre>sudo apt-get install apache2 mysql-server php5 php5-cli<br/>sudo apt-get install php5-mysql libapache2-mod-php5</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Time to setup that vhosts mount point on the guest system. 
<pre>sudo mkdir /var/www/vhosts<br/>sudo chmod 777 /var/www/vhosts<br/>sudo vi /etc/fstab</pre>
and add the line <code>vhosts /var/www/vhosts vboxsf iocharset=utf8,umask=000,uid=33 0 0</code>
<pre>sudo mount vhosts<br/>df -h /var/www/vhosts</pre>
and you should see the disk info for you host system disk, now mounted under Linux
<pre>Filesystem            Size  Used Avail Use% Mounted on<br/>vhosts                269G  174G   96G  65% /var/www/vhosts</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Now, finish up the host-guest networking. From the VirtualBox app on the host, select Preferences... in the File menu. <br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/VirtualBoxPreferencesMenu.png" alt="VirtualBoxPreferencesMenu.png"  title=""http://morison.biz/></span></span>
Choose the Network settings. You should have a "VirtualBox Host-Only Ethernet Adapter network" already listed. (This network was used for your Adapter 2 setup above.) Select the little screwdriver icon and edit the details of that Host-only network. For mine, I turn off the builtin DHCP server, and set the network address to a range that doesn't conflict with anything on my other private networks:<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/HostOnlyNetworkConfig.png" alt="HostOnlyNetworkConfig.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  I'm going to setup 3 guest IPs on the Host-only because that's what I need for the current project. I'm going to use Apache IP Virtual Hosts, which are required for https vhosting. If you have only 1 site, or all your sites are http and can use the Name Virtual Host directive, you only need one. <p class="caution"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/caution.gif" width="10" height="10" alt="!!!" /> I tried Gnutls for SSL Name Vhosting...I'll spare the details, but give it a pass.</p>Back on the guest, append the following to /etc/network/interfaces, e.g., <code>sudo vi /etc/network/interfaces</code>
<pre>auto eth1:0<br/>iface eth1:0 inet static<br/>name Ethernet alias LAN card<br/>address 192.168.56.11<br/>netmask 255.255.255.0<br/>broadcast 192.168.56.255<br/>network 192.168.56.0<br/><br/>auto eth1:1<br/>iface eth1:1 inet static<br/>name Ethernet alias LAN card<br/>address 192.168.56.12<br/>netmask 255.255.255.0<br/>broadcast 192.168.56.255<br/>network 192.168.56.0<br/><br/>auto eth1:2<br/>iface eth1:2 inet static<br/>name Ethernet alias LAN card<br/>address 192.168.56.13<br/>netmask 255.255.255.0<br/>broadcast 192.168.56.255<br/>network 192.168.56.0</pre>
and then
<pre>sudo update-rc.d -f networking remove<br/>sudo update-rc.d networking defaults<br/>sudo /etc/init.d/networking restart<br/>ifconfig</pre>
and <code>ifconfig</code> should give you something like
<pre>eth0      Link encap:Ethernet  HWaddr 08:00:27:41:86:02  <br/>          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0<br/>          inet6 addr: fe80::a00:27ff:fe41:8602/64 Scope:Link<br/>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br/>          RX packets:30837 errors:0 dropped:0 overruns:0 frame:0<br/>          TX packets:15654 errors:0 dropped:0 overruns:0 carrier:0<br/>          collisions:0 txqueuelen:1000 <br/>          RX bytes:46594350 (46.5 MB)  TX bytes:853804 (853.8 KB)<br/>          Interrupt:11 Base address:0xc020 <br/><br/>eth1      Link encap:Ethernet  HWaddr 08:00:27:ff:f6:55  <br/>          inet6 addr: fe80::a00:27ff:feff:f655/64 Scope:Link<br/>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br/>          RX packets:298 errors:0 dropped:0 overruns:0 frame:0<br/>          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0<br/>          collisions:0 txqueuelen:1000 <br/>          RX bytes:48980 (48.9 KB)  TX bytes:6287 (6.2 KB)<br/>          Interrupt:10 Base address:0xc240 <br/><br/>eth1:0    Link encap:Ethernet  HWaddr 08:00:27:ff:f6:55  <br/>          inet addr:192.168.56.11  Bcast:192.168.56.255  Mask:255.255.255.0<br/>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br/>          Interrupt:10 Base address:0xc240 <br/><br/>eth1:1    Link encap:Ethernet  HWaddr 08:00:27:ff:f6:55  <br/>          inet addr:192.168.56.12  Bcast:192.168.56.255  Mask:255.255.255.0<br/>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br/>          Interrupt:10 Base address:0xc240 <br/><br/>eth1:2    Link encap:Ethernet  HWaddr 08:00:27:ff:f6:55  <br/>          inet addr:192.168.56.13  Bcast:192.168.56.255  Mask:255.255.255.0<br/>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br/>          Interrupt:10 Base address:0xc240 <br/><br/>lo        Link encap:Local Loopback  <br/>          inet addr:127.0.0.1  Mask:255.0.0.0<br/>          inet6 addr: ::1/128 Scope:Host<br/>          UP LOOPBACK RUNNING  MTU:16436  Metric:1<br/>          RX packets:40 errors:0 dropped:0 overruns:0 frame:0<br/>          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0<br/>          collisions:0 txqueuelen:0 <br/>          RX bytes:3290 (3.2 KB)  TX bytes:3290 (3.2 KB)</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  On Windows (use notepad) add to <code>\Windows\System32\drivers\etc\hosts</code>:
<pre>192.168.56.10   myhost<br/>192.168.56.11   dev.mysite1.com<br/>192.168.56.12   dev.mysite2.com<br/>192.168.56.13   dev.mysite3.com</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  On the guest add to <code>/etc/hosts</code>
<pre>192.168.56.10   myhost<br/>192.168.56.11   dev.mysite1.com<br/>192.168.56.12   dev.mysite2.com<br/>192.168.56.13   dev.mysite3.com</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Check your work with a ping on the host. Open a command window and <code>ping dev.mysite1.com</code><br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/GuestIpPing.png" alt="GuestIpPing.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Ok, time to setup an Apache IP Virtual Host. I'll just script out a vanilla sample, your setup will certainly vary. On the Linux guest system:
<pre>sudo a2enmod ssl<br/>sudo mkdir -p /var/www/vhosts/mysite1.com/httpdocs<br/>sudo mkdir -p /var/www/vhosts/mysite1.com/log/<br/>sudo vi /etc/apache2/sites-available/dev.mysite1.com</pre>
and add the following vhost setup on one of the IPs you created above. <p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> The certs are Ubuntu standard issue. If you're on a different distro...</p>
<pre>&amp;lt;VirtualHost 192.168.56.11:80><br/>	ServerName   dev.mysite1.com<br/>	ServerAdmin  "me@mysite1.com"<br/>	DocumentRoot /var/www/vhosts/mysite1.com/httpdocs<br/>	CustomLog  /var/www/vhosts/mysite1.com/log/access_log combined<br/>	ErrorLog  /var/www/vhosts/mysite1.com/log/error_log<br/><br/>	&amp;lt;IfModule mod_ssl.c><br/>		SSLEngine off<br/>	&amp;lt;/IfModule><br/><br/>	&amp;lt;Directory /var/www/vhosts/mysite1.com/httpdocs><br/>	    &amp;lt;IfModule mod_php5.c><br/>		php_admin_flag engine on<br/>		php_admin_flag safe_mode off<br/>	    &amp;lt;/IfModule><br/>	    Options +Includes +ExecCGI<br/>	&amp;lt;/Directory><br/><br/>&amp;lt;/VirtualHost><br/><br/><br/>&amp;lt;VirtualHost 192.168.56.11:443><br/>	ServerName   dev.mysite1.com:443<br/>	ServerAdmin  "me@mysite1.com"<br/>	DocumentRoot /var/www/vhosts/mysite1.com/httpdocs<br/>	CustomLog  /var/www/vhosts/mysite1.com/log/ssl_access_log combined<br/>	ErrorLog  /var/www/vhosts/mysite1.com/log/ssl_error_log<br/><br/>	SSLEngine on<br/>	SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem<br/>	SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key<br/><br/>	&amp;lt;Directory /var/www/vhosts/mysite1.com/httpdocs><br/>	    &amp;lt;IfModule mod_php5.c><br/>		php_admin_flag engine on<br/>		php_admin_flag safe_mode off<br/>	    &amp;lt;/IfModule><br/>	    Options +Includes +ExecCGI<br/>	&amp;lt;/Directory><br/><br/>&amp;lt;/VirtualHost></pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Complete the Apache config with
<pre>sudo a2ensite dev.mysite1.com<br/>sudo /etc/init.d/apache2 restart<br/>[/snippet[<br/>and a nice bit of housekeeping &amp;lt;code>sudo vi apache2.conf&amp;lt;/code>, find and after the ServerRoot directive add<br/>[snippet]<br/>ServerName "MySite"</pre>
or whatever you'd like to call it.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Now, check that Apache is good with a testfile on the guest
<pre><code><span style="color: #000000">
echo &amp;gt;/var/www/vhosts/mysite1.com/httpdocs/phpinfo.php '<span style="color: #0000BB">&amp;lt;?php<br />    phpinfo</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&amp;gt;</span>'</span></code>
</pre>
and from the host browse to <code>http://dev.mysite1.com/phpinfo.php</code> and <code>https://dev.mysite1.com/phpinfo.php</code>. You should see<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/61/PhpInfo.png" alt="PhpInfo.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  That's it for this walkthrough. No doubt your config will vary, but this should give you the bones if you want to try this approach. Here are a couple next steps.
<ul><li> Install mysql tools on the guest:
<pre>sudo apt-get install mysql-admin mysql-query-browser</pre>
</li><li> Setup the <a href="http://www.nusphere.com/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">PhpEd</a> debugger extension on the guest, configure a Website Project under vhosts/mysite1.com on the host, and debug from host to guest. When you edit and save files on the host side, they're already in place for Apache running in the guest, thanks to the vhosts mount. 
</li><li> Tune down the mysql &amp; apache params for dev loads, make your VM a little more host friendly. <a href="http://www.linode.com/wiki/index.php/MySQL_and_Apache_Optimization_Guide" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Linode</a> has a nice guide to this end. 
</li><li> While you're tuning mysql, you may want to enable slow query logging. In <code>/etc/mysql/my.cnf</code> uncomment
<pre>log_slow_queries        = /var/log/mysql/mysql-slow.log<br/>long_query_time = 2<br/>log-queries-not-using-indexes</pre>
</li><li> Also in <code>/etc/mysql/my.cnf</code> change the bind-address for access from the windows host:
<pre>bind-address            = 0.0.0.0</pre>
</li><li> If you're using it, make InnoDB the default storage engine
sudo echo >/etc/mysql/conf.d/default_storage_engine.cnf "[mysqld]
default-storage-engine = InnoDB"</li></ul></body>
		<dc:creator>rod</dc:creator>
		<category>Sysadmin</category>
		<pubDate>Thu, 21 Jan 2010 01:48:33 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/61#comments</comments>
		<slash:comments>5</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/61</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/61</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:61</trackback:ping>
	</item>

	<item>
		<title>Better Broadband Bandwidth Utilization Using Wondershaper on a Linux Router to Limit the Uplink</title>
		<link>http://morison.biz/technotes/articles/62</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/62</guid>
		<description>Since I did some streaming video experiments in the early years of this century I've known that maxing both directions of an internet connection kills throughput. I did some experiments, initially to improve my SIP Phone performance (when my son is playing online games, TBH) and came up with a &quot;low-hanging fruit&quot; solution</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Since I did some streaming video experiments in the early years of this century I've known that maxing both directions of an internet connection kills throughput. I did some experiments, initially to improve my SIP Phone performance (when my son is playing online games, TBH) and came up with a "low-hanging fruit" solution.</div>
I'll spare the gory details, but if you study "canonical" TCP congestion algorithms and experiment on how they behave, you quickly find that maxing out both directions of a full duplex TCP pipe just kills performance all around. If you're interested in the ground up details, the best place to start is the classic work, <a href="http://www.kohala.com/start/tcpipiv1.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">TCP/IP Illustrated Vol 1</a>. Much of this book's lore was woven into early network devices (and drivers) and remains much intact, afaict. <br />
<br />
<p class="caution"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/caution.gif" width="10" height="10" alt="!!!" /> To use Wondershaper, you'll have to use a Linux computer as your router. Afaik, most basic broadband routers don't provide traffic limiting features. Setting up a Linux router for your broadband is not a good first-time Linux project. For more info, perhaps look at <a href="http://en.wikipedia.org/wiki/List_of_router_or_firewall_distributions" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://en.wikipedia.org/wiki/List_of_router_or_firewall_distributions</a> or <a href="http://www.stanford.edu/~fenn/linux/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.stanford.edu/~fenn/linux/</a> . It's not terribly difficult to do with a standard <a href="http://www.ubuntu.com/products/whatIsubuntu/serveredition" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Ubuntu Server</a> distro, which is what I use.</p>If you want to cut to the chase, and improve your internet connection bandwidth, here's how I finagled the problem. First, I went to my ISPs bandwidth testing site late at night, when I knew not much else was happening on my connection. This effect can be had by shutting down everything except one bandwidth testing computer and your router. Better is to take that computer straight into the internet connection, but that was way too much work for my purposes. (And, would have involved way too much time in my basement!)<br />
<br />
For me <a href="http://www.speakeasy.net" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">www.speakeasy.net</a> provides a nice testing service at <a href="http://www.speakeasy.net/speedtest/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.speakeasy.net/speedtest/</a> . I can't say whether this will suffice for non-speakeasy users. However, after running this test several times, I settled on a 3621 kbits/sec downlink and a 630 kbits/sec uplink as a baseline.<br />
<br />
Then, use whatever traffic shaping tool you have to experiment with throughput at and below those values. The easiest, admittedly blunt knife, tool that I've found is <a href="http://lartc.org/wondershaper/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Wondershaper</a>. Wondershaper is available in Ubuntu, i.e.
<pre>sudo apt-get install wondershaper</pre>
Also, in the Ubuntu docs, you may find <a href="http://ubuntuforums.org/archive/index.php/t-25911.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://ubuntuforums.org/archive/index.php/t-25911.html</a> useful...I certainly did.<br />
<br />
In my case, with the 3621/630 profile, I tried Wondershaper at 3500/650, 4000/650, 4000/625 and 4000/600. To stress the connection, I tried a series of tests with 1-2 downloads and 0-2 uploads. I used <a href="http://www.eos.ncsu.edu/remoteaccess/man/scp.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">scp</a> to a hosted server of mine that can reliably max out my connection. Scp is nice because it prints out its bandwidth when it's done, or ^C'd. Yes, scp introduces some overhead, and it doesn't measure true "line" bits. The Flash based Speakeasy test uses the Flash plugin, but this isn't rocket science, right? Suffice it to say, there are far bigger holes in my methodology...but time is money, as they say, and I declared "victory" without having to be more precise.<br />
<br />
Without getting into details (you can back my inference out of the graphs below) I concluded that my connection is insensitive to downlink shaping, but terribly sensitive to uplink shaping. Without shaping, whenever an upload was going full-bore, I lost 80-90% of my download bandwidth. By throttling uplink to 90-95% of the max, I got a big chunk of that back. With the throttled uplink my downloads only lost 10-30% of their speed, quite an improvement.<br />
<br />
No time or space for the rationale, but anyone familiar with the term "TCP Round Trip ACK" can quickly imagine why. See <a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol_" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Wikipedia's TCP entry</a>. Better yet, get the <a href="http://www.kohala.com/start/tcpipiv1.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Steven's Book</a>, it's one of the best technical books every written, IMHO.<br />
<br />
So here's the pretty picture. Bandwidth on the Y axis. My 5 traffic scenarios on the X. And a differently colored line for each shaping scenario. Which would you rather have? <br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/62/TrafficShapingChart.png" alt="TrafficShapingChart.png"  title=""http://morison.biz/></span></span><br />
<br />
And, even if you don't want to shape your traffic, when your teenager's Youtube upload brings everyones browsing in the house to a crawl, at least you'll know why. Which begs the question: why aren't these features built into home broadband routers or, better yet, into the TCP framework of broadband service providers!?<br />
<br />
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> Postscript: For those interested, a good bit of research has been done on this problem, particularly under the name of <a href="http://en.wikipedia.org/wiki/FAST_TCP" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">FastTCP</a>. <a href="http://fastsoft.com" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://fastsoft.com</a> is commercial spinoff of that project and has some <a href="http://fastsoft.com/white-papers/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">pertinent white papers</a> on the subject.</p></body>
		<dc:creator>rod</dc:creator>
		<category>Sysadmin</category>
		<pubDate>Fri, 07 Aug 2009 04:43:00 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/62#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/62</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/62</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:62</trackback:ping>
	</item>

	<item>
		<title>Convert a .crt Certificate to a .pem file</title>
		<link>http://morison.biz/technotes/articles/60</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/60</guid>
		<description>Every year or so I update CA'd certs and usually forget that my mailserver (cyrus+postfix) needs a PEM format file. Then, I have to fish around for the openssl commands that do the job</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Every year or so I update CA'd certs and usually forget that my mailserver (cyrus+postfix) needs a PEM format file. Then, I have to fish around for the openssl commands that do the job.</div>
<pre>openssl x509 -in morison.org.crt -out morison.org.der -outform DER<br/>openssl x509 -in morison.org.der -inform DER -out morison.org.pem -outform PEM<br/>sudo cp ./morison.org.pem /etc/ssl/certs/<br/>sudo /etc/init.d/cyrus2.2 restart<br/>sudo /etc/init.d/postfix restart</pre>
Thanks for <a href="http://moze.koze.net/?p=81" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://moze.koze.net/?p=81</a> for the reminder this time.</body>
		<dc:creator>rod</dc:creator>
		<category>Sysadmin</category>
		<pubDate>Thu, 23 Apr 2009 00:13:59 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/60#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/60</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/60</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:60</trackback:ping>
	</item>

	<item>
		<title>VirtualBox for Ubuntu on Vista 64 (The VMWare Killer for Developer VMs?)</title>
		<link>http://morison.biz/technotes/articles/58</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/58</guid>
		<description>Ok, that's an overstatement. I used VMWare Workstation successfully for a year to develop for Win2k web servers on my XP desktop. However, when I needed an Ubuntu guest on Windows Vista host (for Python/TurboGears dev), VMWare got ugly with various host apps.
I searched...and I found...VirtualBox.

This doc is a loose how-to, because some steps were poorly documented</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Ok, that's an overstatement. I used VMWare Workstation successfully for a year to develop for Win2k web servers on my XP desktop. However, when I needed an Ubuntu guest on Windows Vista host (for Python/TurboGears dev), VMWare got ugly with <a href="http://communities.vmware.com/message/1062725;jsessionid=A1A01540B8DEAF31480E239DCDB63395" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">various host apps</a>.
I searched...and I found...VirtualBox.<br />
<br />
This doc is a loose how-to, because some steps were poorly documented.</div>
<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Go to the <a href="http://www.virtualbox.org/wiki/Downloads" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">VirtualBox download site</a> and get the appropriate Windows host installer (x86 or AMD64). Install VirtualBox.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Go get the <a href="http://www.ubuntu.com/getubuntu/download" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">install iso for your guest OS</a>.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Start VirtualBox, and click the "New" tool. The wizard is straightforward. Before starting the VM, be sure to mount your installer .iso as the CD.<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/58/VirtualBoxNew.png" alt="VirtualBoxNew.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Powerup and install. The VM will capture the mouse when you click in it, and you'll need the "uncapture" key to get it back, right ctrl by default, I recall. I remap to the "Left Windows" key (personal preference.) However, once you install the guest and install the VBoxGuestAdditions on top, your VM can "play nice" with the host for mouse capture, copy/paste, etc.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Therein lies the rub: the VBoxGuestAdditions install was _not_ that clearly documented. Even finding it was a bit tricky. By following the url of an older version from an <a href="http://ubuntuforums.org/showthread.php?p=6633107" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">ubuntu forums thread</a> I backed out that I should look under <a href="http://download.virtualbox.org/virtualbox/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://download.virtualbox.org/virtualbox/</a> , or specifically <a href="http://download.virtualbox.org/virtualbox/2.1.2/VBoxGuestAdditions_2.1.2.iso" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">the 2.1.2 VBoxGuestAdditions download</a> from <a href="http://download.virtualbox.org/virtualbox/2.1.2/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">this webdir</a>.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  To install the guest additions, I actually had to <a href="http://download.virtualbox.org/virtualbox/2.1.2/UserManual.pdf" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">RTFM</a>, particularly section "4.3.1 Installing the Linux Guest Additions"<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Add, then mount the VBoxGuestAdditions.iso (from the Devices menu of the VM). <br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/58/VirtualBoxMountIso.png" alt="VirtualBoxMountIso.png"  title=""http://morison.biz/></span></span><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  If/when a popup in the guest OS asks to automatically run software, say "Cancel"<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Open a shell on the guest (Applications->Accessories->Terminal, for Ubuntu Desktop). You'll need to install DKMS, then run the guest additions script, and reboot.
<pre>$ sudo apt-get install dkms<br/>$ sudo sh /cdrom/VBoxLinuxAdditions-x86.run #look for the amd64 if that's your linux guest install<br/>$ sudo reboot</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  ...And presto, your Ubuntu (or other linux) should come up, nicely sharing the mouse point with Vista, auto-resizing the guest desktop when the host window changes, and so on.<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Proceed to bring your guest OS up to date, and do watchya do.<br />
<br />
<span class="inline_image"><span><img src="http://morison.biz/technotes/images/article/58/UbuntuInVirtualBox.png" alt="UbuntuInVirtualBox.png"  title=""http://morison.biz/></span></span></body>
		<dc:creator>rod</dc:creator>
		<category>Sysadmin</category>
		<pubDate>Fri, 13 Feb 2009 15:23:59 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/58#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/58</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/58</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:58</trackback:ping>
	</item>

	<item>
		<title>My Choice: Best IPTables Tutorial</title>
		<link>http://morison.biz/technotes/articles/57</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/57</guid>
		<description>This link is hands down the best tutorial of IpTables I've come across</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">This link is hands down the best tutorial of IpTables I've come across.</div>
Linux IpTables can be confounding. I usually create a rule and try it out with tcpdumps running on both sides, sort of a "hail Mary" approach. A <i>careful</i> read-through of <a href="http://iptables-tutorial.frozentux.net/iptables-tutorial.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Iptables Tutorial 1.2.2</a> really straightened me out. <br />
<br />
In particular, the <a href="http://iptables-tutorial.frozentux.net/iptables-tutorial.html#DNATTARGET" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">DNAT Target</a> section finally answered my questions, and fixed the issue, with my port forwarded servers not responding to clients from within their masqueraded network.<br />
<br />
A very good read, especially if you've "kinda" figured out IpTables, just enough to be dangerous, but are missing some key points to get rules to do what you want.<br />
<br />
(You can skip the lengthy SCTP coverage, unless that's something you're working with.)<br />
<br />
Once again: <a href="http://iptables-tutorial.frozentux.net/iptables-tutorial.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://iptables-tutorial.frozentux.net/iptables-tutorial.html</a></body>
		<dc:creator>rod</dc:creator>
		<category>Linux</category>
		<pubDate>Tue, 10 Feb 2009 11:48:06 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/57#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/57</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/57</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:57</trackback:ping>
	</item>

	<item>
		<title>PostgreSQL 1A</title>
		<link>http://morison.biz/technotes/articles/56</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/56</guid>
		<description>I spent the last 8 years on a lot of MySQL and little MSSQL. Now, I'm on a PostgreSQL project. Here's my cheat sheet of DBMS specific commands I needed to figure out right away</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">I spent the last 8 years on a lot of MySQL and little MSSQL. Now, I'm on a <a href="http://www.postgresql.org" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">PostgreSQL</a> project. Here's my cheat sheet of DBMS specific commands I needed to figure out right away.</div>
<ul><li>Install on Ubuntu 8.10</li></ul>
<pre>$ sudo apt-get install postgresql-8.3 postgresql-server-dev-8.3<br/>$ sudo vi /etc/postgresql/8.3/main/postgresql.conf <br/># uncomment the listen_addresses = 'localhost' line<br/># optional: change localhost to machine hostaddr if you want outside access<br/>$ sudo /etc/init.d/postgresql-8.3 restart</pre>
<ul><li>Give the "root" db user a password, create a new dbuser and a database with access privs for that new dbuser. Also, give the new dbuser perms to create more databases.</li></ul>
<pre>$ sudo -u postgres psql template1<br/>template1=# ALTER USER postgres WITH UNENCRYPTED PASSWORD 'P8ss';<br/>ALTER ROLE<br/>template1=# CREATE USER user1 CREATEDB;<br/>CREATE ROLE<br/>template1=# ALTER USER user1 WITH UNENCRYPTED PASSWORD 'P9ss';<br/>ALTER ROLE<br/>template1=# CREATE DATABASE db1 WITH OWNER user1;<br/>CREATE DATABASE<br/>template1=# q</pre>
<ul><li>To suck a sqldump into that database</li></ul>
<pre>$ zcat /PathToDbDump/DbDump.sql.gz | psql -h localhost -U postgres -d user1</pre>
<ul><li>Logging in as non-postgres user (this bit baffled me originally, until I decoded the postgres init settings): /etc/postgresql/8.3/main/pg_hba.conf has security settings that say, "If connected via unix socket then require the db username match the process owner name." By default psql uses the unix socket. That's fine for the "root" db user (postgres), but not how you want access other dbs. However, for network socket connections pg_hba.conf is set to use only password check against it's user table. Yay. So access through the socket, which is the general case in production systems anyway, as the db is on a dedicated machine.</li><li>Log in as the user1 and create a db.</li></ul>
<pre>psql --username user1 --password -h localhost template1<br/>CREATE DATABASE db2 WITH OWNER user1;</pre>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> 
<ul><li>if you don't put a db name on the psql command line, it will assume the db name is the same as the user</li><li>postgres provides an easily scripted command, createdb, that does most of what the CREATE DATABASE command does.</li><li>read the postgres docs for encrypted passwords, recommended for production</li></ul>
</p></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Wed, 28 Jan 2009 09:44:28 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/56#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/56</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/56</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:56</trackback:ping>
	</item>

	<item>
		<title>WxPython 2.8 Vista 64 bit crash - workaround found</title>
		<link>http://morison.biz/technotes/articles/55</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/55</guid>
		<description>Originally posted on the wxpython-users list</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Originally posted on the wxpython-users list</div>
I've puzzled over the Vista 64 crashes this past week, and the reports similar to my problem:<br />
<br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://www.nabble.com/wxPython-Crash-td20605396.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.nabble.com/wxPython-Crash-td20605396.html</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://trac.wxwidgets.org/ticket/10203" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://trac.wxwidgets.org/ticket/10203</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://trac.wxwidgets.org/ticket/10082" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://trac.wxwidgets.org/ticket/10082</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://www.python-forum.org/pythonforum/viewtopic.php?f=4&amp;p=46918" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.python-forum.org/pythonforum/viewtopic.php?f=4&amp;p=46918</a><br />
<br />
I tried hand patching the supposed fix, <a href="http://trac.wxwidgets.org/changeset/56863," title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://trac.wxwidgets.org/changeset/56863,</a> from the trunk into WX_2_8_BRANCH, but no joy.<br />
<br />
Finally, after going back to wxWidgets C++ apps to see why they didn't crash, I realized wxWidgets apps get built with a different manifest than the python.exe. The diff between the two manifests is in the Common Controls DLL. wxWidgets apps specifically call out the 6.0.0.0 common controls. Common controls is not in the python manifest.<br />
<br />
However, running my debug python, I can see that python.exe loads the 5.82 common controls, and assumed that mismatch was the source of the problem. So, I backed up my c:\Python26\python.exe, merged a manifest with 6.0 common controls into the python.exe and there was rejoicing, i.e., no crash.<br />
<br />
Here's the trick (you'll need the msft manifest tool, mt.exe, comes with visual studio, plus a manifest file with common controls 6.0.0.0, like the one out of the wxPython src distro):<br />
<br />
<pre>cd c:\Python26<br/>copy python.exe python-backup.exe<br/>copy pythonw.exe pythonw-backup.exe<br/>mt -inputresource:python.exe;#1 -manifest \PathToWxPySrc\src\winxp.vc9.manifest  -outputresource:python.exe;#1<br/>mt -inputresource:pythonw.exe;#1 -manifest \PathToWxPySrc\src\winxp.vc9.manifest  -outputresource:pythonw.exe;#1</pre><br />
<br />
The fix <a href="http://trac.wxwidgets.org/changeset/56863" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://trac.wxwidgets.org/changeset/56863</a> in the wxWidgets trunk (2.9 release, I expect) is reported to solve the problem, but I wonder whether it really pulls in the 6.0 common controls dll (for wxPython, that is).</body>
		<dc:creator>rod</dc:creator>
		<pubDate>Fri, 16 Jan 2009 05:23:44 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/55#comments</comments>
		<slash:comments>1</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/55</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/55</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:55</trackback:ping>
	</item>

	<item>
		<title>References, FAQs, Debug &amp; Test Tips</title>
		<link>http://morison.biz/technotes/articles/48</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/48</guid>
		<description>Other How-Tos, FAQs &amp; Ideas for mail system debug</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Other How-Tos, FAQs &amp; Ideas for mail system debug</div>
<h2 id="title_1" >References</h2><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="https://help.ubuntu.com/community/Cyrus" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">https://help.ubuntu.com/community/Cyrus</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://www.postfix.org/SASL_README.html#server_cyrus" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.postfix.org/SASL_README.html#server_cyrus</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://tldp.org/HOWTO/Postfix-Cyrus-Web-cyradm-HOWTO/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://tldp.org/HOWTO/Postfix-Cyrus-Web-cyradm-HOWTO/</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://manpages.ubuntu.com/manpages/hardy/man1/policyd-spf.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://manpages.ubuntu.com/manpages/hardy/man1/policyd-spf.html</a><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  <a href="http://doc.ubuntu.com/ubuntu/serverguide/C/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://doc.ubuntu.com/ubuntu/serverguide/C/</a>
<h2 id="title_2" >Tips &amp; Tricks</h2><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Send mails locally with the Linux command line mail program
<pre>sudo apt-get install mailutils<br/>mail rod@moleculemedia.net -s test<br/>Cc: rod@morison.org<br/>test<br/>^D</pre><br />
<img src="http://morison.biz/technotes/skins/technotes2/icons/bullet.gif" width="7" height="7" alt="-" />  Can't create Sieve files
<pre>sudo bash<br/>cd /var/spool/cyrus/sieve<br/>ls domain<br/>mkdir domain<br/>cp -a [a-z] domain/<br/>chown cyrus:mail domain<br/>chmod o-rwx domain</pre></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Tue, 30 Sep 2008 04:42:14 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/48#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/48</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/48</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:48</trackback:ping>
	</item>

	<item>
		<title>Lockdown</title>
		<link>http://morison.biz/technotes/articles/47</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/47</guid>
		<description>Security Considerations</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Security Considerations</div>
Under Constrution   <img src="http://morison.biz/technotes/skins/images/smileys/winkgrin.gif" alt="" /></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Tue, 30 Sep 2008 04:42:33 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/47#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/47</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/47</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:47</trackback:ping>
	</item>

	<item>
		<title>DNS Preliminaries</title>
		<link>http://morison.biz/technotes/articles/42</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/42</guid>
		<description>Public mail service requires a static IP and DNS support. Here is a quick list of what you need</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Public mail service requires a static IP and DNS support. Here is a quick list of what you need.</div>
<h2 id="title_2" >IP &amp; DNS Setup</h2>
You'll need a static IP and access to the DNS config for you domain. For the static, it's a matter of requesting the static IP from your access provider...if your service supports such...if not, read the commentary at <a href="http://morison.biz/technotes/articles/37" title="Read the article" class="article">The Internet Server Project - Part II - Planning<br />
<br />
</a>.<br />
<br />
For DNS, most likely the registrar for your domain has a web interface for making changes.
<h3 id="title_1" >Checklist</h3>
<ol class="1"><li> A static IP, from your access or hosting provider
</li><li> An 'A' record pointing to a name to your static ip, using a name something like "mailserver.example.domain". In this guide we'll use <i>example.domain</i> as a placeholder for your own domain.
</li><li> An MX record for <i>example.domain</i> which points at <i>mailserver.example.domain</i>
</li><li> CNAME or A records for <i>mail.example.domain</i>, <i>smtp.example.domain</i> and <i>webmail.example.domain</i>. If you use CNAME's, point them at <i>mailserver.example.domain</i>, if A use your static IP.</li></ol>
<h2 id="title_3" >Next Step: <a href="http://morison.biz/technotes/articles/43" title="Read the article" class="article">Ubuntu Install</a></h2></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Tue, 30 Sep 2008 04:42:53 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/42#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/42</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/42</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:42</trackback:ping>
	</item>

	<item>
		<title>Anti-Spam &amp; Anti-Virus Install</title>
		<link>http://morison.biz/technotes/articles/46</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/46</guid>
		<description>Some of the best mail filtering technology the world has to offer...Most of this &quot;just works&quot; out of the Ubuntu installations. We'll add SPF checking directly info Postfix, too</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Some of the best mail filtering technology the world has to offer...Most of this "just works" out of the Ubuntu installations. We'll add SPF checking directly info Postfix, too.</div>
<a href="http://www.ijs.si/software/amavisd/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Amavisd</a> acts as a "master" daemon to pluggable mail scanning modules. We'll install <a href="http://www.clamav.net/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">ClamAV</a> anti-virus and <a href="http://spamassassin.apache.org/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">SpamAssassin</a> anti-spam. The SpamAssassin install will include several powerful spam detection tools, e.g., <a href="http://pyzor.sourceforge.net/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">pyzor</a>, <a href="http://razor.sourceforge.net/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">razor</a>, and others.
<ol class="1"><li> <b>Install the Goods</b>
<pre>sudo apt-get install amavisd-new spamassassin clamav-daemon<br/>sudo apt-get install pyzor razor python-policyd-spf<br/>sudo apt-get install arj cabextract cpio lha nomarch pax rar unrar unzip unzoo zip zoo</pre>
</li><li> <b>Add clamav to amavis group</b>
<pre>sudo adduser clamav amavis</pre>
</li><li> <b>Enable SpamAssassin</b> - 
<pre>sudo vi /etc/default/spamassassin</pre>
and change line 8 to <code>ENABLED=1</code>
</li><li> <b>Tell Amavis to Virus &amp; Spam Check</b>
<pre>sudo vi /etc/amavis/conf.d/15-content_filter_mode</pre>
and uncomment the virus &amp; spam check lines as shown:
<pre>@bypass_virus_checks_maps = (<br/>   %bypass_virus_checks, @bypass_virus_checks_acl, $bypass_virus_checks_re);</pre>
...
<pre>@bypass_spam_checks_maps = (<br/>   %bypass_spam_checks, @bypass_spam_checks_acl, $bypass_spam_checks_re);</pre>
</li><li> <b>Set Local Policy Prefs</b>
<pre>sudo vi /etc/amavis/conf.d/50-user</pre>
My policy is to tag, but pass all spam. Viruses are not delivered, but the postmaster is notified and the email is quarantined, such that it can be recovered if need be. You may want to study the Amavis docs and customize here.<br />
<br />
Change <code>example.domain</code> to yours. My <code>50-user</code> reads
<pre>use strict;<br/><br/>#<br/># Place your configuration directives here.  They will override those in<br/># earlier files.<br/>#<br/># See /usr/share/doc/amavisd-new/ for documentation and examples of<br/># the directives you can use in this file<br/>#<br/><br/>$log_level = 0;<br/><br/>@local_domains_maps =<br/>   ( [ ".$mydomain", 'example.domain' ] ); <br/><br/>$sa_spam_subject_tag = '<b>*SPAM</b>* ';<br/>$sa_tag_level_deflt  = -999;  # add spam info headers if at, or above that level<br/>$sa_tag2_level_deflt = 5.0; # add 'spam detected' headers at that level<br/>$sa_kill_level_deflt = 999; # triggers spam evasive actions<br/>$sa_dsn_cutoff_level = 10;   # spam level beyond which a DSN is not sent<br/><br/>$virus_admin = "postmaster@$mydomain"; # due to D_DISCARD default<br/>$spam_admin = "postmaster@$mydomain";<br/>$dsn_bcc = "maildebug@$mydomain";<br/><br/>$mailfrom_notify_admin     = "virusalert@$mydomain";<br/>$mailfrom_notify_recip     = "virusalert@$mydomain";<br/>$mailfrom_notify_spamadmin = "spamalert@$mydomain";<br/><br/>$final_virus_destiny      = D_DISCARD;  # (data not lost, see virus quarantine)<br/>$final_banned_destiny     = D_REJECT;   # D_REJECT when front-end MTA<br/>$final_spam_destiny       = D_PASS;<br/>$final_bad_header_destiny = D_PASS;     # False-positive prone (for spam)<br/><br/>#------------ Do not modify anything below this line -------------<br/>1;  # ensure a defined return</pre>
</li><li> <b>Integrate Amavisd into Postfix</b>
<pre>sudo vi /etc/postfix/main.cf</pre>
Add the following to the bottom of <code>/etc/postfix/main.cf</code>
<pre># Amavis ClamAV+SpamAssassin<br/>content_filter = smtp-amavis:[127.0.0.1]:10024<br/><br/># Postfix behavior/content controls<br/>#body_checks = regexp:/etc/postfix/body_checks<br/>#header_checks = regexp:/etc/postfix/header_checks<br/>smtpd_helo_required = yes<br/>disable_vrfy_command = yes<br/>smtpd_delay_reject = yes<br/>smtpd_helo_required = yes<br/>smtpd_error_sleep_time = 15s<br/>smtpd_soft_error_limit = 10<br/>smtpd_hard_error_limit = 20</pre>
</li><li> <b><code>/etc/postfix/master.cf</code></b>
<pre>sudo vi /etc/postfix/master.cf</pre>
Add the two "-o" lines shown under the line beginning with "pickup", to read:
<pre>pickup    fifo  n       -       -       60      1       pickup<br/>         -o content_filter=<br/>         -o receive_override_options=no_header_body_checks</pre>
Then add the following to the bottom of <code>/etc/postfix/master.cf</code>
<pre>smtp-amavis     unix    -       -       -       -       2       smtp<br/>        -o smtp_data_done_timeout=1200<br/>        -o smtp_send_xforward_command=yes<br/>        -o disable_dns_lookups=yes<br/>        -o max_use=20<br/><br/>127.0.0.1:10025 inet    n       -       -       -       -       smtpd<br/>        -o content_filter=<br/>        -o local_recipient_maps=<br/>        -o relay_recipient_maps=<br/>        -o smtpd_restriction_classes=<br/>        -o smtpd_delay_reject=no<br/>        -o smtpd_client_restrictions=permit_mynetworks,reject<br/>        -o smtpd_helo_restrictions=<br/>        -o smtpd_sender_restrictions=<br/>        -o smtpd_recipient_restrictions=permit_mynetworks,reject<br/>        -o smtpd_data_restrictions=reject_unauth_pipelining<br/>        -o smtpd_end_of_data_restrictions=<br/>        -o mynetworks=127.0.0.0/8<br/>        -o smtpd_error_sleep_time=0<br/>        -o smtpd_soft_error_limit=1001<br/>        -o smtpd_hard_error_limit=1000<br/>        -o smtpd_client_connection_count_limit=0<br/>        -o smtpd_client_connection_rate_limit=0<br/>        -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks</pre>
</li><li> <b><a href="http://www.openspf.org/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">SPF</a> in Postfix</b> - SPF is already a part of SpamAssassin's scoring scheme. We can further utilize SPF in Postfix to reflect sites that disapprove certain usage and reject those messages outright. I recommend a read through of materials on the SPF site and relevant discussion lists. <br />
<br />
You can omit this step if you choose.
<pre>sudo vi /etc/postfix/main.cf</pre>
Add a comma to the end of the last line of the <code>smtpd_recipient_restrictions</code> settings and on a new line add
<pre>check_policy_service unix:private/policyd-spf</pre>
followed by
<pre>policyd-spf_time_limit = 3600</pre>
This section of your <code>main.cf</code> should look something like
<pre>smtpd_recipient_restrictions =<br/>        permit_sasl_authenticated,<br/>        permit_mynetworks,<br/>        reject_unauth_destination,<br/>        reject_invalid_hostname,<br/>        reject_non_fqdn_hostname,<br/>        reject_non_fqdn_sender,<br/>        reject_non_fqdn_recipient,<br/>        reject_unknown_sender_domain,<br/>        reject_unknown_recipient_domain,<br/>        reject_unauth_pipelining<br/>        reject_rbl_client bl.spamcop.net,<br/>        reject_rbl_client sbl-xbl.spamhaus.org,<br/>        reject_rbl_client list.dsbl.org,<br/>        check_policy_service unix:private/policyd-spf<br/>policyd-spf_time_limit = 3600</pre>
In master.cf:
<pre>sudo vi /etc/postfix/master.cf</pre>
At the bottom, add
<pre>policyd-spf  unix  -       n       n       -       0 spawn<br/>        user=nobody argv=/usr/bin/python /usr/bin/policyd-spf</pre>
</li><li> <b>Start/Restart All Concerned</b>
<pre>sudo /etc/init.d/postfix restart<br/>sudo /etc/init.d/amavis restart<br/>sudo /etc/init.d/clamav-daemon restart<br/>sudo /etc/init.d/spamassassin start</pre>
</li><li> <b>Test and Check</b> - Try another mail send and watch the log.
<pre>tail -f /var/log/mail.log</pre>
Look for the logfile line
<pre>Sep 29 13:50:25 mailserver amavis[8449]: (08449-01) Passed CLEAN, LOCAL [192.168.66.194] [192.168.66.194] &amp;lt;test@mailserver.morison.org> -> &amp;lt;test@mailserver.morison.org>, Message-ID: &amp;lt;48E13F6D.1010202@mailserver.morison.org>, mail_id: 8HLb1RzoY+ZW, Hits: -1.44, size: 564, queued_as: EC77724624, 3852 ms</pre>
for anti-spam action. Try it with a spam file (I'm sure you can find one.) You'll see
<pre>Sep 29 13:52:55 mailserver amavis[8454]: (08454-01) Passed SPAMMY, LOCAL [192.168.66.194] [192.168.66.194] &amp;lt;test@mailserver.morison.org> -> &amp;lt;test@mailserver.morison.org>, Message-ID: &amp;lt;48E13FFB.7000908@mailserver.morison.org>, mail_id: moC25mDhimPK, Hits: 8.824, size: 649, queued_as: 4B5E624624, 12174 ms</pre>
and look at the mail headers in your mail client:
<pre>X-Virus-Scanned: Debian amavisd-new at mailserver.morison.org<br/>X-Spam-Flag: YES<br/>X-Spam-Score: 8.824<br/>X-Spam-Level: <b>*</b>***<br/>X-Spam-Status: Yes, score=8.824 tagged_above=-999 required=5<br/>	tests=[ALL_TRUSTED=-1.44, AWL=-10.264, DIGEST_MULTIPLE=0.001,<br/>	PYZOR_CHECK=2.834, RAZOR2_CF_RANGE_51_100=0.5,<br/>	RAZOR2_CF_RANGE_E4_51_100=1.5, RAZOR2_CF_RANGE_E8_51_100=1.5,<br/>	RAZOR2_CHECK=0.5, URIBL_AB_SURBL=1.613, URIBL_JP_SURBL=2.857,<br/>	URIBL_OB_SURBL=2.132, URIBL_SBL=2.468, URIBL_SC_SURBL=2.523,<br/>	URIBL_WS_SURBL=2.1]</pre>
Finally, try sending a test virus from (the virus is dead, of course, but it triggers a ClamAV find):<br />
<br />
<a href="http://www.eicar.org/download/eicar.com" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.eicar.org/download/eicar.com</a> 
<a href="http://www.eicar.org/download/eicar_com.zip" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.eicar.org/download/eicar_com.zip</a>
<a href="http://www.eicar.org/download/eicarcom2.zip" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.eicar.org/download/eicarcom2.zip</a><br />
<br />
Look for
<pre>Sep 29 14:07:56 mailserver amavis[8449]: (08449-02) Blocked INFECTED (Eicar-Test-Signature), LOCAL [192.168.66.194] [192.168.66.194] &amp;lt;test@mailserver.morison.org> -> &amp;lt;test@mailserver.morison.org>, quarantine: J/virus-JfYri+IcyuAB, Message-ID: &amp;lt;48E1438B.5060502@mailserver.morison.org>, mail_id: JfYri+IcyuAB, Hits: -, size: 1062, 934 ms</pre>
and check your postmaster email.</li></ol><br />
<br />
<h2 id="title_1" >Epilogue</h2>
You're done, really. There are some security issues that could be better, discussed further in <a href="http://morison.biz/technotes/articles/47" title="Read the article" class="article">Lockdown</a>. (Yes, I know, passwords sitting the in filesystem plain readable, but they gotta get in, first.)</body>
		<dc:creator>rod</dc:creator>
		<pubDate>Tue, 30 Sep 2008 04:43:12 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/46#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/46</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/46</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:46</trackback:ping>
	</item>

	<item>
		<title>Web-Cyradm Install</title>
		<link>http://morison.biz/technotes/articles/45</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/45</guid>
		<description>Web-Cyradm provides web based admin of accounts, quotas and domains, along with domain level admins. Installation is not difficult...as long as you use the right version and settings</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">Web-Cyradm provides web based admin of accounts, quotas and domains, along with domain level admins. Installation is not difficult...as long as you use the right version and settings.</div>
<h2 id="title_1" >Preliminaries</h2>
You'll need to come up with 4 passwords for this section. The first 3 are entirely internal. Once configured, the passwords should be tucked away and not needed, except in an emergency debug of some kind.
<ol class="1"><li> <b>MySQL "root" user</b> - Don't run MySQL without a root user password. The installer will ask for it. Note that this is a database user, internal to MySQL and having nothing to do with login users or mail users.
</li><li> <b>MySQL "mail" user</b> - Another MySQL user, for accessing the soon to be created mail database.
</li><li> <b>Web-Cyradm "cyrus" user</b> - When we configured /etc/cyrus.conf we designated "cyrus" as an admin user. Web-Cyradm will need this user, and we'll set the password when we configure Web-Cyradm. This user is internal to the Web-Cyradm app.
</li><li> <b>Web-Cyradm "admin" user</b> - This is the initial admin user once the website is up and running.</li></ol>
Jot those passwords down in a safe place.
<h2 id="title_2" >Apache + PHP</h2>
Web-Cyradm is a PHP app that uses a MySQL db. Let's start with Apache &amp; PHP.
<ol class="1"><li> <b>Install apache2 with php</b>
<pre>sudo apt-get install apache2 php5 libapache2-mod-php5 php5-cli php5-mysql</pre>
</li><li> <b>PEAR &amp; imap support</b> - Used by Web-Cyradm &amp; webmail apps
<pre>sudo apt-get install php-db php5-imap</pre>
</li><li> <b>Open Port 80</b>
<pre>sudo ufw allow http</pre>
</li><li> <b>Test Apache+PHP</b>
<pre><code><span style="color: #000000">
echo "<br /><span style="color: #0000BB">&amp;lt;?php<br />print_r </span><span style="color: #007700">(</span><span style="color: #0000BB">phpinfo</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&amp;gt;</span>" &amp;gt;/tmp/phpinfo.php<br />sudo mv /tmp/phpinfo.php /var/www<br />sudo /etc/init.d/apache2 restart</span></code>
</pre>
Browse to <code>http://mailserver.example.domain/phpinfo.php</code>
</li><li> <b>Clean up</b>
<pre>sudo rm /var/www/phpinfo.php</pre></li></ol>
<h2 id="title_3" >MySQL with PAM &amp; Postfix Config</h2>
<ol class="1"><li> <b>Install MySQL Server</b> - The installer will ask for that MySQL root password.
<pre>sudo apt-get install mysql-server</pre>
</li><li> <b>Relocate MySQL Socket to Postfix Chroot</b> - Just like we tweaked the saslauthd socket, we need the same for Postfix to access MySQL. Stop MySQL first, as it gets confused when these files change underneath it.
<pre>sudo /etc/init.d/mysql stop<br/>sudo vi /etc/mysql/my.cnf</pre>
and prepend all of the references to <code>/var/run/mysqld</code> to read <code>/var/spool/postfix/var/run/mysqld</code>. In the current config that affects lines 21, 28, 43 &amp; 44. Lines 19-44 should look like
<pre>[client]<br/>port            = 3306<br/>socket          = /var/spool/postfix/var/run/mysqld/mysqld.sock<br/><br/># Here is entries for some specific programs<br/># The following values assume you have at least 32M ram<br/><br/># This was formally known as [safe_mysqld]. Both versions are currently parsed.<br/>[mysqld_safe]<br/>socket          = /var/spool/postfix/var/run/mysqld/mysqld.sock<br/>nice            = 0<br/><br/>[mysqld]<br/>#<br/># * Basic Settings<br/>#<br/><br/>#<br/># * IMPORTANT<br/>#   If you make changes to these settings and your system uses apparmor, you may<br/>#   also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.<br/>#<br/><br/>user            = mysql<br/>pid-file        = /var/spool/postfix/var/run/mysqld/mysqld.pid<br/>socket          = /var/spool/postfix/var/run/mysqld/mysqld.sock</pre>
</li><li> <b>Update <code>/etc/mysql/debian.cnf</code></b>
<pre>sudo vi /etc/mysql/debian.cnf</pre>
and change the "socket" lines to the new location, e.g.,
<pre># Automatically generated for Debian scripts. DO NOT TOUCH!<br/>[client]<br/>host     = localhost<br/>user     = debian-sys-maint<br/>password = 8JCDXsC4cUmDn8Pm<br/>socket   = /var/spool/postfix/var/run/mysqld/mysqld.sock<br/>[mysql_upgrade]<br/>user     = debian-sys-maint<br/>password = 8JCDXsC4cUmDn8Pm<br/>socket   = /var/spool/postfix/var/run/mysqld/mysqld.sock<br/>basedir  = /usr</pre>
</li><li> <b>Update <a href="http://en.wikipedia.org/wiki/Apparmor" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">apparmor</a></b>
<pre>sudo vi /etc/apparmor.d/usr.sbin.mysqld</pre>
and make the appropriate mods to the /var/run/mysqld lines at the bottom:
<pre>/var/spool/postfix/var/run/mysqld/mysqld.pid w,<br/>  /var/spool/postfix/var/run/mysqld/mysqld.sock w,<br/>}</pre>
Then reload the apparmor profile
<pre>sudo /etc/init.d/apparmor restart</pre>
</li><li> <b>Start MySQL and Fix Sockets</b> - Remember that <code>/etc/init.d/fix-postfix-chroot</code> init script we installed? MySQL wasn't running when we ran it, so after MySQL starts, we need to run it again.
<pre>sudo /etc/init.d/mysql restart<br/>sudo /etc/init.d/fix-postfix-chroot start<br/>sudo ls -l /var/run/saslauthd /var/run/mysqld</pre>
should give you
<pre>lrwxrwxrwx 1 root root 33 2008-09-29 12:55 /var/run/mysqld -> /var/spool/postfix/var/run/mysqld<br/>lrwxrwxrwx 1 root root 36 2008-09-29 12:55 /var/run/saslauthd -> /var/spool/postfix/var/run/saslauthd</pre>
</li><li> <b>Configure PAM for mail DB</b> - /etc/pam.d/common-mysqlmail is a new PAM file, to include in other service files.
<pre>sudo apt-get install libpam-mysql<br/>sudo vi /etc/pam.d/common-mysqlmail</pre>
Then copy the following into this new file, updating the mysql mail user password from changeme:
<pre>#<br/># MySQL Web-Cyradm mail database authorization<br/>#<br/>auth sufficient pam_mysql.so user=mail passwd=changeme host=localhost db=mail table=accountuser usercolumn=username passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg logusercolumn=user loghostcolumn=host logpidcolumn=pid logtimecolumn=time<br/><br/>account required pam_mysql.so user=mail passwd=changeme host=localhost db=mail table=accountuser usercolumn=username passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg logusercolumn=user loghostcolumn=host logpidcolumn=pid logtimecolumn=time</pre>
</li><li> <b>Update PAM services</b> - To use the MySQL mail auth
<pre>sudo vi /etc/pam.d/imap /etc/pam.d/pop /etc/pam.d/sieve</pre>
In each of these files, comment out the <code>@include common-auth</code> and <code>@include common-account</code> lines. Add a <code>@include common-mysqlmail</code> below them. The last 3 lines should read
<pre>#@include common-auth<br/>#@include common-account<br/>@include common-mysqlmail</pre>
Add those same 3 lines to a new PAM file, <code>/etc/pam.d/smtp</code>
<pre>sudo vi /etc/pam.d/smtp</pre>
</li><li> <b>Configure Postfix for mail DB</b>
<pre>sudo apt-get install postfix-mysql</pre>
</li><li> <b>Update main.cf</b>
<pre>sudo vi /etc/postfix/main.cf</pre>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> The setting for <code>virtual_mailbox_maps</code> below is <b>critical</b> to avoid getting tagged as a spammer due to <a href="http://en.wikipedia.org/wiki/Outscatter" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">backscatter spam</a>.</p>
and at the bottom add the lines
<pre># Mysql glue<br/>virtual_alias_maps =<br/>        mysql:/etc/postfix/mysql-virtual.cf<br/>virtual_mailbox_maps = <br/>        mysql:/etc/postfix/mysql-virtual.cf<br/>virtual_mailbox_domains =<br/>        mysql:/etc/postfix/mysql-mydestination.cf<br/>sender_canonical_maps =<br/>        mysql:/etc/postfix/mysql-canonical.cf</pre>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> The following 3 MySQL scripts are from <a href="http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/postfix-config.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.delouw.ch/linux/Postfix-Cyrus-Web-cyradm-HOWTO/html/postfix-config.html</a> here.</p>
</li><li> <b>Create <code>/etc/postfix/mysql-virtual.cf</code> </b>
<pre>sudo vi /etc/postfix/mysql-virtual.cf</pre>
...adding the following and setting "changeme" to the MySQL mail user password:
<pre>#<br/># mysql config file for alias lookups on postfix<br/># comments are ok.<br/>#<br/><br/># the user name and password to log into the mysql server<br/>hosts = localhost<br/>user = mail<br/>password = changeme<br/><br/># the database name on the servers<br/>dbname = mail<br/><br/># the table name<br/>table = virtual<br/><br/>#<br/>select_field = dest<br/>where_field = alias<br/>additional_conditions = and status = '1'</pre>
</li><li> <b>Create <code>/etc/postfix/mysql-mydestination.cf</code> </b>
<pre>sudo vi /etc/postfix/mysql-mydestination.cf</pre>
...adding the following and setting "changeme" to the MySQL mail user password:
<pre># mysql config file for local domain (like sendmail's sendmail.cw) lookups on postfix<br/># comments are ok.<br/>#<br/><br/># the user name and password to log into the mysql server<br/>hosts = localhost<br/>user = mail<br/>password = changeme<br/><br/># the database name on the servers<br/>dbname = mail<br/><br/># the table name<br/>table = domain<br/>#<br/>select_field = domain_name<br/>where_field = domain_name</pre>
</li><li> <b>Create <code>/etc/postfix/mysql-canonical.cf</code> </b>
<pre>sudo vi /etc/postfix/mysql-canonical.cf</pre>
...adding the following and setting "changeme" to the MySQL mail user password:
<pre># mysql config file for canonical lookups on postfix<br/># comments are ok.<br/>#<br/><br/># the user name and password to log into the mysql server<br/>hosts = localhost<br/>user = mail<br/>password = changeme<br/><br/># the database name on the servers<br/>dbname = mail<br/><br/># the table name<br/>table = virtual<br/>#<br/>select_field = alias<br/>where_field = username<br/># Return the first match only<br/>additional_conditions = and status = '1' limit 1</pre>
</li><li> <b>Restart postfix</b> - ...and make sure it started clean.
<pre>sudo /etc/init.d/postfix restart<br/>tail /var/log/mail.log</pre></li></ol>
<h2 id="title_4" >Update Cyrus &amp; Saslauthd configs</h2>
As presently configured, Cyrys &amp; Saslauthd expect to work with simple usernames, not <script type="text/javascript">document.write('<a href="' + 'mailto:user' + '@' + 'domain' + '" class="email" title="Send a message">' + 'Send a message' + '</a>')</script><noscript><p>Please enable JavaScript to see this address</p></noscript> type addresses. For them to work together, and with the PAM to mail db link, the following is needed:
<ol class="1"><li> <b>/etc/default/saslauthd</b> - Add a -r flag to the last line, so that it reads:
<pre>OPTIONS="-r -c -m /var/spool/postfix/var/run/saslauthd"</pre>
</li><li> <b>/etc/imapd.conf</b> - Scroll down to the <code>virtdomains</code> setting and uncomment the line so it reads
<pre>virtdomains: userid</pre>
</li><li> Restart cyrus &amp; saslauthd
<pre>sudo /etc/init.d/saslauthd restart<br/>sudo /etc/init.d/cyrus2.2 restart</pre></li></ol>
<h2 id="title_5" >Web-Cyradm</h2>
Finally, install and config the webapp. <b>You will need the 0.5.5 version</b> as of this writing. Only this (and perhaps upcoming) versions work correctly with Cyrus's virtdomain feature. Get it from <a href="http://www.web-cyradm.org/web-cyradm-svn-0.5.5.tar.gz_" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">the source</a>, or there's a copy here: <a href="http://morison.biz/technotes/files/6-web-cyradm-svn-0-5-5-tar.gz" title="View file details" class="file">Web-Cyradm 0.5.5 tarball</a>
<ol class="1"><li> <b>Place Web-Cyradm</b>
<pre>wget http://www.web-cyradm.org/web-cyradm-svn-0.5.5.tar.gz<br/>cd /var/www<br/>sudo tar xzf ~/web-cyradm-svn-0.5.5.tar.gz</pre>
</li><li> <b>Put Passwords in SQL Init Scripts</b>
<pre>cd web-cyradm-svn-0.5.5/<br/>sudo vi scripts/insertuser_mysql.sql<br/>sudo vi scripts/create_mysql.sql</pre>
</li><li> <b><code>insertuser_mysql.sql</code>, line 2</b> - change the 'secret' text on line 2 to the password for the MySQL mail db user. This line creates that user with that password.
</li><li> <b><code>create_mysql.sql</code>, line 135</b> - change 'test' at line 135 to the password for the Web-Cyradm admin account (not the cyrus account, btw.) This will be your first login id for Web-Cyradm when you browse to it, i.e., admin/adminpassword. This line creates that user with that password.
</li><li> <b><code>create_mysql.sql</code>, line 137</b> - change 'secret' to the password for the cyrus user in the Web-Cyradm 'mail' database. This password will be used in the Web-Cyradm config (covered later.) This line creates that user with that password.
</li><li> <b>Run SQL init scripts</b> - You'll need your MySQL root password for the first command, and your MySQL mail db password for the second.
<pre>mysql -u root -p &amp;lt;scripts/insertuser_mysql.sql<br/>mysql mail -u mail -p &amp;lt;scripts/create_mysql.sql</pre>
</li><li> <b>Web-Cyradm App Config</b>
<pre>cd /var/www/web-cyradm-svn-0.5.5/config<br/>sudo cp conf.php.dist conf.php<br/>sudo vi conf.php</pre>
and edit the following
</li><li> <b><code>conf.php</code>, line 19</b> - replace <code>secret</code> with the cyrus password (see <code>create_mysql.sql</code>, line 137).
</li><li> <b><code>conf.php</code>, line 37</b> - replace <code>secret</code> with the mysql mail password (see <code>insertuser_mysql.sql</code>, line 2).
</li><li> <b><code>conf.php</code>, line 89</b>, set <code>$DOMAIN_AS_PREFIX = 1</code>
</li><li> <b><code>conf.php</code>, line 100</b>, set <code>$FQUN = 1</code></li></ol>
<h2 id="title_6" >Mailadmin Site Config</h2>
Almost ready to browse. We just need to tell Apache some things about the site and turn it on.
<ol class="1"><li> <b>Get the <a href="http://morison.biz/technotes/files/7-mailadmin.conf" title="View file details" class="file">Apache mailadmin config file</a> File</b> - ...install and enable
<pre>sudo wget http://morison.biz/technotes/file-fetch/7-mailadmin.conf<br/>sudo cp 7-mailadmin.conf /etc/apache2/sites-available/mailadmin<br/>sudo a2ensite mailadmin<br/>sudo /etc/init.d/apache2 restart</pre>
</li><li> <b>Browse and Login</b> - with the admin password (from <code>create_mysql.sql</code>, line 135) to <a href="http://mailserver.example.domain/mailadmin" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://mailserver.example.domain/mailadmin</a></li></ol>
<h2 id="title_7" >Create a Domain, Email Account &amp; Test</h2>
If you've successfully browsed and logged in to your mailadmin site you should be looking at:<br />
<br />
<span class="frame_image"><span><img src="http://morison.biz/technotes/images/article/45/Web-CyradmInstall-02.png" alt="Web-Cyradm Browse Domains Screen"  title="Web-Cyradm Browse Domains Screen"http://morison.biz/></span><span class="image_caption">Web-Cyradm Browse Domains Screen</span></span>
<ol class="1"><li> <b>Add a Domain</b> - Click on the "Add New Domain" link. In this form be sure to update "Domainname", "Maximum Accounts" (or your account limit for the domain will be zero) and "Standard Folders". "Standard Folders is important, to create the default folders most mail clients expect. This field should read
<pre>Drafts,Sent,Junk,Trash</pre><br />
<br />
Set the "Default Quota" up or down, as you require and submit the form. Your form should look something like (modified fields circled in red)<br />
<br />
<span class="frame_image"><span><img src="http://morison.biz/technotes/images/article/45/Web-CyradmInstall-03.png" alt="Web-Cyradm Add New Domain Screen"  title="Web-Cyradm Add New Domain Screen"http://morison.biz/></span><span class="image_caption">Web-Cyradm Add New Domain Screen</span></span>
</li><li> <b>Create an Account</b> - from the Browse Domains screen, click "accounts" in the domain list.
</li><li> <b>Test</b> - Tail the mail log, send email to/from the account, retrieve it via imap and/or pop, and reply (with your favorite mail client.) Try with and without TLS.
<pre>tail -f /var/log/mail.log</pre>
you should see something like
<pre>Sep 29 13:03:07 mailserver postfix/smtpd[5639]: connect from unknown[192.168.66.194]<br/>Sep 29 13:03:07 mailserver postfix/smtpd[5639]: 8BB0B245F2: client=unknown[192.168.66.194], sasl_method=PLAIN, sasl_username=test@mailserver.morison.org<br/>Sep 29 13:03:07 mailserver postfix/cleanup[5645]: 8BB0B245F2: message-id=&amp;lt;48E1345C.7020804@mailserver.morison.org><br/>Sep 29 13:03:07 mailserver postfix/qmgr[4654]: 8BB0B245F2: from=&amp;lt;test@mailserver.morison.org>, size=564, nrcpt=1 (queue active)<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: accepted connection<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: lmtp connection preauth'd as postman<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: WARNING: sieve script /var/spool/cyrus/sieve/domain/m/mailserver.morison.org/t/test/defaultbc doesn't exist: No such file or directory<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: duplicate_check: &amp;lt;48E1345C.7020804@mailserver.morison.org> mailserver.morison.org!user.test 0<br/>Sep 29 13:03:07 mailserver postfix/smtpd[5639]: disconnect from unknown[192.168.66.194]<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: duplicate_check: &amp;lt;48E1345C.7020804@mailserver.morison.org> mailserver.morison.org!user.test 0<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: mystore: starting txn 2147483660<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: mystore: committing txn 2147483660<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: duplicate_mark: &amp;lt;48E1345C.7020804@mailserver.morison.org> mailserver.morison.org!user.test 1222718587 2<br/>Sep 29 13:03:07 mailserver cyrus/lmtpunix[5657]: Delivered: &amp;lt;48E1345C.7020804@mailserver.morison.org> to mailbox: mailserver.morison.org!user.test<br/>Sep 29 13:03:07 mailserver postfix/lmtp[5649]: 8BB0B245F2: to=&amp;lt;test@mailserver.morison.org>, relay=mailserver.morison.org[/var/run/cyrus/socket/lmtp], delay=0.2, delays=0.09/0/0.01/0.1, dsn=2.1.5, status=sent (250 2.1.5 Ok)<br/>Sep 29 13:03:07 mailserver postfix/qmgr[4654]: 8BB0B245F2: removed</pre></li></ol>
<h2 id="title_8" >You're Up and Running!</h2>
Next up, <a href="http://morison.biz/technotes/articles/46" title="Read the article" class="article">Anti-Spam &amp; Anti-Virus Install</a></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Sat, 05 Sep 2009 10:27:07 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/45#comments</comments>
		<slash:comments>2</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/45</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/45</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:45</trackback:ping>
	</item>

	<item>
		<title>Postfix &amp; Cyrus Install</title>
		<link>http://morison.biz/technotes/articles/44</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/44</guid>
		<description>How to get email services up, configured and talking to each other</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">How to get email services up, configured and talking to each other</div>
<h2 id="title_1" >Ssh Access</h2>
Assuming you have a server up and responding on it's static IP as described in the <a href="http://morison.biz/technotes/articles/43" title="Read the article" class="article">Ubuntu Install</a> section, you can continue to work on the console, or ssh into the server. In the long run you'll probably ssh most of the time, as you can do it from just about anywhere on the internet (with an ssh program, that is.)<br />
<br />
If you've got a OS X Mac, BSD or Linux computer, ssh should already be available from the command line. If you're on Windows, get <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Putty</a> or <a href="http://cygwin.com/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Cygwin</a> (make sure you include the openssh package in the cygwin install.) I'll use the command line ssh in examples. You can peruse the Putty docs and achieve the same results.<br />
<br />
ssh to the server (subbing your loginid and mailserver dns name, of course)
<pre>ssh -p 9999 loginid@mailserver.example.domain</pre>
This means of access has the plus of being able to copy/paste between windows, amongst others.<br />
<br />
<h2 id="title_2" >Postfix Install &amp; Config</h2>
<ol class="1"><li> <b>Install the Postfix Package</b>
<pre>sudo apt-get install postfix</pre>
The package installer will bring up 3 screens. Ok the first one, choose Internet Site for the second, and make sure the full name, with domain part (the <a href="http://en.wikipedia.org/wiki/FQDN" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">FQDN</a>) is in the 3rd screen.<br />
<br />
<span class="center_image"><a href="http://morison.biz/technotes/images/27"><span><img src="http://morison.biz/technotes/images/article/44/thumbs/PostfixCyrusInstall-01.png" alt="Postfix Package Config"  title="Postfix Package Config"http://morison.biz/></span></a><span class="image_caption">Postfix Package Config</span></span>
<span class="center_image"><a href="http://morison.biz/technotes/images/28"><span><img src="http://morison.biz/technotes/images/article/44/thumbs/PostfixCyrusInstall-02.png" alt="Postfix Config Type"  title="Postfix Config Type"http://morison.biz/></span></a><span class="image_caption">Postfix Config Type</span></span>
<span class="center_image"><a href="http://morison.biz/technotes/images/29"><span><img src="http://morison.biz/technotes/images/article/44/thumbs/PostfixCyrusInstall-03.png" alt="Postfix Mail Name"  title="Postfix Mail Name"http://morison.biz/></span></a><span class="image_caption">Postfix Mail Name</span></span>
</li><li> <b>main.cf config</b>
<pre>sudo vi /etc/postfix/main.cf</pre>
Find the "# TLS parameters" line and right underneath it add
<pre>smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt</pre>
This file doesn't exist yet, but we'll install it later. It's not necessary for self-signed certs, like the snakeoil automatically generated cert, but getting this in place now makes referencing a CA signed cert a snap later.<br />
<br />
Next, add the following to the end of the file:
<pre># SASL parameters<br/>smtpd_sasl_local_domain =<br/>smtpd_sasl_auth_enable = yes<br/>smtpd_sasl_security_options = noanonymous<br/>broken_sasl_auth_clients = yes<br/><br/># Client &amp; recipient restrictions<br/>smtpd_recipient_restrictions =<br/>        permit_sasl_authenticated,<br/>        permit_mynetworks,<br/>        reject_unauth_destination,<br/>        reject_invalid_hostname,<br/>        reject_non_fqdn_hostname,<br/>        reject_non_fqdn_sender,<br/>        reject_non_fqdn_recipient,<br/>        reject_unknown_sender_domain,<br/>        reject_unknown_recipient_domain,<br/>        reject_unauth_pipelining<br/>        reject_rbl_client bl.spamcop.net,<br/>        reject_rbl_client sbl-xbl.spamhaus.org,<br/>        reject_rbl_client list.dsbl.org<br/>smtpd_client_restrictions = permit_mynetworks,<br/>        check_client_access hash:/etc/postfix/access<br/>smtpd_sender_restrictions = <br/>        reject_non_fqdn_sender,<br/>        check_sender_access hash:/etc/postfix/access,<br/>        check_sender_mx_access hash:/etc/postfix/access<br/><br/># LMTP<br/>message_size_limit = 20480000<br/>mailbox_transport = lmtp:unix:/var/run/cyrus/socket/lmtp<br/>virtual_transport = lmtp:unix:/var/run/cyrus/socket/lmtp</pre>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> Some things to look at and possibly modify in your setup:
<ul><li> The SASL setup is for authentication. We'll install SASL with Cyrus. 
</li><li> smtpd_recipient_restrictions settings are set to a strong anti-spam policy, e.g., rejecting anything from any of the 3 RBLs. It is definitely worth understanding this and the 2 following parameters which control whether Postfix accepts or rejects mail. See <a href="http://www.postfix.org/SMTPD_ACCESS_README.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">the Postfix docs</a> on the subject. It's also worth reading up on <a href="http://en.wikipedia.org/wiki/DNSBL" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">RBLs</a> if you're not familiar with how they work.
</li><li> LMTP is how Postfix will hand off mail for delivery to mailboxes...the Cyrus LMTP service will listen on the other end. I use a large setting, 20MB, for message_size_limit because it suits my email user base. Choose your poison here.</li></ul>
</p>
</li><li> <b>Copy in (or create an empty) access file</b> - The references to /etc/postfix/access above are for an in-house blacklist. Up until 2006 I diligently fished out the sending mail IP from spam and added it to an access file. I'm providing my copy of this file; though no longer updated, it still manages to block a batch of spams every day, and I haven't had a complaint in years about a false positive. To use this file, copy it to your /etc/postfix directory and run. If you'd rather not, just use touch to create a blank file...you might want the feature someday.<br />
<br />
<a href="http://morison.biz/technotes/files/5-access.txt" title="View file details" class="file">Postfix "blacklist" access db</a>
<pre>sudo touch /etc/postfix/access<br/>sudo cp access.txt /etc/postfix/access #skip if not using<br/>sudo postmap /etc/postfix/access</pre>
</li><li> <b>master.cf config</b>
<pre>sudo vi /etc/postfix/master.cf</pre>
Look for the first uncommented line starting with <code>smtp</code> and add a "-d" at the end. This flag will turn on debug messages in the log, useful at this stage of the game.
<pre>smtp      inet  n       -       -       -       -       smtpd -d</pre>
Then scroll down to the line beginning with <code>lmtp</code> and change the 3rd dash to read "n". This will make lmtp not run in <a href="http://en.wikipedia.org/wiki/Chroot" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">chroot</a> jail. As a security issue it's acceptably minor, as lmtp runs behind postfix, i.e., isn't exposed to outside access, plus we'll use <a href="http://en.wikipedia.org/wiki/Unix_socket" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">unix sockets</a> for the Cyrus interface.
<pre>lmtp      unix  -       -       n       -       -       lmtp</pre>
</li><li> <b>Add postfix user to mail group</b> - I would have expected the installer package to do this. Needed so Cyrus and Postfix can share the LMTP socket, which will use group file access bits.
<pre>sudo adduser postfix mail</pre>
</li><li> <b>Restart Postfix</b>
<pre>sudo /etc/init.d/postfix restart</pre></li></ol>
<h2 id="title_3" >Cyrus Install &amp; Config</h2>
<ol class="1"><li> <b>Install Cyrus Packages</b>
<pre>sudo apt-get install cyrus-admin-2.2 cyrus-clients-2.2 cyrus-imapd-2.2 sasl2-bin cyrus-pop3d-2.2</pre>
</li><li> <b>Move &amp; Fix Cyrus Dirs</b> - Two things to change, one is a matter of taste, the other a show-stopper installer mistake. The matter of taste is the storage for <a href="http://en.wikipedia.org/wiki/Sieve__mail_filtering_language_" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Sieve</a>, Cyrus's server side mail filtering technology (and one of the reasons I like Cyrus). Ubuntu puts that storage in <code>/var/spool/sieve</code> and mailbox storage in <code>/var/spool/cyrus/mail</code>. I like to keep it under one roof, so we'll move Sieve storage under cyrus and update the appropriate config file.<br />
<br />
The stopper is the perms on the cyrus dirs. Try <code>ls -la /var/spool/cyrus</code> and you'll see
<pre>total 16<br/>drwxr-xr-x  4 cyrus mail 4096 2008-09-28 13:28 .<br/>drwxr-xr-x  6 root  root 4096 2008-09-28 13:28 ..<br/>drwxr-x--- 29 root  root 4096 2008-09-28 13:28 mail<br/>drwxr-x--- 29 root  root 4096 2008-09-28 13:28 news</pre>
The dirs under <code>/var/spool/cyrus</code> are all owned by root:root and 750. (If 750 doesn't ring a bell, it's worth reading some <a href="http://en.wikipedia.org/wiki/File_system_permissions#Notation_of_traditional_Unix_permissions" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">docs on Linux file perms</a>.)
Hence, the cyrus programs, which will run under cyrus:mail, can't write to the mail storage. I'd call that a bug. Same deal with <code>/var/lib/cyrus</code>: Once Cyrus tries to do something useful, like put mail in a mailbox, it barfs because it can't read/write it's working files.<br />
<br />
Oh, and because we're going to change perms to something only cyrus &amp; root users can see, we'll go into "perma-root" mode temporarily. I recommend getting out of the root shell when done with this step.
<pre>sudo bash<br/>cd /var/spool/cyrus/<br/>mv /var/spool/sieve/ .<br/>chown -R cyrus:mail .<br/>chmod -R o-rwx .<br/>ls -la<br/>cd /var/lib/cyrus/<br/>chown -R cyrus:mail .<br/>ls -la<br/>exit</pre>
</li><li> <b>/etc/cyrus.conf</b> - Cyrus, like Postfix, runs with a master daemon that dispatches other programs to handle different services. /etc/cyrus.conf is where the master is configured. (Fyi, once you're up and running try <code>ps axu | grep master</code> and you should  see both master processes.)
<pre>sudo vi /etc/cyrus.conf</pre>
Move down to the SERVICES section, uncomment the imaps and pop3s services. These will give you secure pop3 and imap, over ssl. Comment out the nntp service (unless you want to run the old "netnews" service, not covered further here; anyone remember "alt"?.) Also, verify that the lmtpunix line is <b>not</b> commented, and the lmtp line is. The top of your SERVICES section should look like
<pre>SERVICES {<br/>        # --- Normal cyrus spool, or Murder backends ---<br/>        # add or remove based on preferences<br/>        imap            cmd="imapd -U 30" listen="imap" prefork=0 maxchild=100<br/>        imaps           cmd="imapd -s -U 30" listen="imaps" prefork=0 maxchild=100<br/>        pop3            cmd="pop3d -U 30" listen="pop3" prefork=0 maxchild=50<br/>        pop3s           cmd="pop3d -s -U 30" listen="pop3s" prefork=0 maxchild=50<br/>        #nntp           cmd="nntpd -U 30" listen="nntp" prefork=0 maxchild=100<br/>        #nntps          cmd="nntpd -s -U 30" listen="nntps" prefork=0 maxchild=100<br/><br/>        # At least one form of LMTP is required for delivery<br/>        # (you must keep the Unix socket name in sync with imap.conf)<br/>        #lmtp           cmd="lmtpd" listen="localhost:lmtp" prefork=0 maxchild=20<br/>        lmtpunix        cmd="lmtpd" listen="http://morison.biz/var/run/cyrus/socket/lmtp" prefork=0 maxchild=20</pre>
</li><li> <b>Enable Squatter</b> - This step is optional, depending on your application. Squatter is a full-text indexing daemon that will speed up "Search Entire Message" requests by 10x or more. If you run a smaller number of more demanding users (like I do), enable as shown. If you're running a horde of freebie accounts on limited resources, skip this step. It will add processing load to your system, but only if your mail and user activity is very high. If in doubt, try it, and disable it from this file if necessary.<br />
<br />
Again, in <code>/etc/cyrus.conf</code> move down to the "EVENTS" section and uncomment the two "squatter" lines to read
<pre># reindex changed mailboxes (fulltext) approximately every other hour<br/>        squatter_1      cmd="http://morison.biz/usr/bin/nice -n 19 /usr/sbin/squatter -s" period=120<br/><br/>        # reindex all mailboxes (fulltext) daily<br/>        squatter_a      cmd="http://morison.biz/usr/sbin/squatter" at=0517</pre>
With or without squatter, save and exit <code>/etc/cyrus.conf</code>
</li><li> <b>/etc/imapd.conf</b> - The service specific settings for imap, pop3, lmtp, sieve, etc. are in <code>/etc/imapd.conf</code>
<pre>sudo vi /etc/imapd.conf</pre>
First, find the "unixhierarchysep" line (approx line 28) and change the setting to "yes". Using this feature gives a more natural syntax which will correlate with how we config Web-Cyradm. The line should read
<pre>unixhierarchysep: yes</pre>
Continue down to the line that reads "#admins: cyrus". Web-cyradm will use this ID for privileged mailbox operations (like creating &amp; deleting mailboxes). There is also a command line interface that can use this ID, cyradm, which should only be needed for debugging. The line should read:
<pre>admins: cyrus</pre>
On down to the line beginning "sievedir", which we change to correspond to the new location:
<pre>sievedir: /var/spool/cyrus/sieve</pre>
Now, look for "sasl_mech_list". This setting defines what imap, pop3 and smtp password formats are available. Uncomment, and set to "PLAIN LOGIN".
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> Yes, these are both unencrypted formats. There are PAM issues upcoming that force this hand. That said, if you use the encrypted services: imaps, pop3s and smtp/tls with your email client, no readable passwords are exposed.</p>
The line should read
<pre>sasl_mech_list: PLAIN LOGIN</pre>
Continue to the line beginning "sasl_pwcheck_method". Change this to "saslauthd", a daemon which will, in turn, use pam authentication machinery. The line should read:
<pre>sasl_pwcheck_method: saslauthd</pre>
Next, go to "tls_cert_file" and uncomment this line and the "tls_key_file" line, leaving this setting pointing to the default, self signed "snakeoil" key for your machine. If you obtain a CA signed cert, change the .pem and .key file locations here. These lines should read.
<pre># File containing the global certificate used for ALL services (imap, pop3,<br/># lmtp, sieve)<br/>tls_cert_file: /etc/ssl/certs/ssl-cert-snakeoil.pem<br/><br/># File containing the private key belonging to the global server certificate.<br/>tls_key_file: /etc/ssl/private/ssl-cert-snakeoil.key</pre>
Finally, go to the line with "tls_ca_file" and uncomment. changing the value to "http://morison.biz/etc/ssl/certs/ca-certificates.crt". This file isn't needed for self-signed certs. We'll install it later, though, so when CA'd certs come in, we just repoint the cert and key settings. This line should read:
<pre>tls_ca_file: /etc/ssl/certs/ca-certificates.crt</pre>
Save and exit <code>/etc/imapd.conf</code> and restart Cyrus
<pre>sudo /etc/init.d/cyrus2.2 restart</pre></li></ol>
<h2 id="title_4" >Saslauthd Config</h2>
We installed sasl2-bin with Cyrus. <a href="http://www.imc.org/ietf-sasl/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Sasl</a> will connect Cyrus &amp; Postfix to Pam authentication, and Pam will be configured to ask a Mysql database, maintained by Web-Cyradm for password verification. 
<ol class="1"><li> <b>/etc/default/saslauthd</b>
<pre>sudo vi /etc/default/saslauthd</pre>
Change the "START=no" line to read
<pre>START=yes</pre>
And, down at the bottom of the file update the sasl unix socket to run inside Postfix jail. Change the last line to read
<pre>OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"</pre>
</li><li> <b>etc/postfix/sasl/smtpd.conf</b> - Create a new file, <code>/etc/postfix/sasl/smtpd.conf</code>, i.e., 
<pre>sudo vi /etc/postfix/sasl/smtpd.conf</pre>
with the following contents:
<pre>pwcheck_method: saslauthd<br/>mech_list: plain login</pre>
</li><li> <b>Add postfix to the sasl group</b> - For socket access
<pre>sudo adduser postfix sasl</pre>
</li><li> <b>Start saslauthd</b>
<pre>sudo /etc/init.d/saslauthd start</pre></li></ol>
<h2 id="title_5" >SSL Bits</h2>
Postfix and Cyrus's ssl configs are ready to go, except for a minor detail, read access to the private keys. While we're at it, we'll get that <code>/etc/ssl/certs/ca-certificates.crt</code> file installed:
<pre>sudo adduser cyrus ssl-cert<br/>sudo adduser postfix ssl-cert<br/>sudo apt-get install ca-certificates</pre>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> If you do install a CA supplied cert, you'll probably have a .crt you need to convert to a .pem file mail apps. Here's the trick:
<pre>openssl x509 -in mydomain.crt -out mydomain.der -outform der<br/>openssl x509 -in mydomain.der -inform der -out mydomain.pem -outform pem</pre>
</p>
<h2 id="title_6" >Postfix Chroot Jail Fix</h2>
We're almost there, but we have a problem: Postfix needs to talk to two services via unix sockets, saslauthd and mysql (to be installed later), but the standard location for those sockets in /var/run are not in Postfix jail, i.e., /var/spool/postfix. We could move those sockets to /var/spool/postfix and use "ln -s" to put them back in /var/run, where other programs expect them. However, /var/run gets cleaned out on boot and we lose those links. <br />
<br />
Solution: Add an /etc/init.d script that runs does the job <i>after</i> mysql and saslauthd startup and create their sockets. We already set saslauthd's config (above) to open it's socket in /var/spool/postfix. However, ASAIK Cyrus is hardwired to look in /var/run. Mysql presents a similar issue for other apps when we install it in the next section. Create <code>/etc/init.d/postfix-fixchroot</code>:
<ol class="1"><li> <b>Create /etc/init.d/fix-postfix-chroot</b>
<pre>sudo vi /etc/init.d/fix-postfix-chroot</pre>
and add the lines:
<pre>#!/bin/sh -e<br/># Fixup socket paths in /var/run because of moves to postfix chroot @ /var/spool/postfix<br/>#<br/><br/># BEGIN INIT INFO<br/># Provides:          fixes in /var/run<br/># Required-Start:    $local_fs $remote_fs<br/># Required-Stop:     $local_fs $remote_fs<br/># Should-Start:      saslauthd mysql postfix<br/># Should-Stop:       saslauthd mysql postfix<br/># Default-Start:     2 3 4 5<br/># Default-Stop:      0 1 6<br/># Short-Description: Fixup socket paths in /var/run because of moves to postfix chroot @ /var/spool/postfix<br/># Description:<br/># END INIT INFO<br/><br/>PATH=/bin:/usr/bin:/sbin:/usr/sbin<br/>TZ=<br/>unset TZ<br/><br/>. /lib/lsb/init-functions<br/>#DISTRO=$(lsb_release -is 2>/dev/null || echo Debian)<br/><br/>case "$1" in<br/>    start)<br/>        log_daemon_msg "Try to fix sockets in postfix chroot"<br/>        if [ ! -e "http://morison.biz/var/run/mysqld" ] &amp;&amp; [ -e /var/spool/postfix/var/run/mysqld ] ; then<br/>                log_daemon_msg "ln -s /var/spool/postfix/var/run/mysqld /var/run"<br/>                ln -s /var/spool/postfix/var/run/mysqld /var/run<br/>        fi<br/>        if [ ! -e "http://morison.biz/var/run/saslauthd" ] &amp;&amp; [ -e /var/spool/postfix/var/run/saslauthd ] ; then<br/>                log_daemon_msg "ln -s /var/spool/postfix/var/run/saslauthd /var/run"<br/>                ln -s /var/spool/postfix/var/run/saslauthd /var/run<br/>        fi<br/>    ;;  <br/><br/>    stop)<br/>        log_daemon_msg "Cleaning up sockets in postfix chroot"<br/>        if [ -h "http://morison.biz/var/run/mysqld" ]; then<br/>                log_daemon_msg "rm /var/run/mysqld"<br/>                rm /var/run/mysqld<br/>        fi<br/>        if [ -h "http://morison.biz/var/run/saslauthd" ]; then<br/>                log_daemon_msg "rm /var/run/saslauthd"<br/>                rm /var/run/saslauthd<br/>        fi<br/>    ;;  <br/>esac    <br/><br/>exit 0</pre>
</li><li> <b>Setup fix-postfix-chroot</b> - Remove the old /var/run/saslauthd and setup the init script:
<pre>sudo rmdir /var/run/saslauthd<br/>sudo chmod +x /etc/init.d/fix-postfix-chroot<br/>sudo update-rc.d fix-postfix-chroot multiuser 90<br/>sudo /etc/init.d/fix-postfix-chroot start<br/>sudo ls -l /var/run/saslauthd/</pre></li></ol>
<h2 id="title_7" >Root &amp; Postmaster Aliases</h2>
I recommend starting out you use an email address not on this server for root and postmaster messages. This setup anticipates some anti-virus/spam aliases. Once things are running smoothly, you might change to a local account.
<ol class="1"><li> <b>Add Admin Email Addresses</b> - Edit <code>/etc/aliases</code> to read
<pre>root:   myeverydaymailaddress<br/>postmaster: myeverydaymailaddress<br/><br/>clamav:                  postmaster<br/>webmaster:               postmaster<br/>maildebug:               postmaster<br/>virusalert:              postmaster<br/>spamalert:               postmaster</pre>
</li><li> <b>Run newaliases &amp; reload Postfix</b>
<pre>sudo newaliases <br/>sudo postfix reload</pre></li></ol>
<h2 id="title_8" >Test the Machinery</h2>
Two useful test tools are <code>imtest</code> and <code>smtptest</code>. Run them now, and auth with you Linux login to test that everything's working so far:
<ol class="1"><li> <b>IMAP</b>
<pre>imtest -a mylogin</pre>
and you should get an imap handshake and a password prompt. Use your shell login password
<pre>WARNING: no hostname supplied, assuming localhost<br/><br/>S: * OK mailserver Cyrus IMAP4 v2.2.13-Debian-2.2.13-13ubuntu3 server ready<br/>C: C01 CAPABILITY<br/>S: * CAPABILITY IMAP4 IMAP4rev1 ACL QUOTA LITERAL+ NAMESPACE UIDPLUS ID NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE IDLE STARTTLS<br/>S: C01 OK Completed<br/>Please enter your password: <br/>C: L01 LOGIN rod {8}<br/>S: + go ahead<br/>C: &amp;lt;omitted><br/>S: L01 OK User logged in<br/>Authenticated.<br/>Security strength factor: 0</pre>
^C out of this and check the log file
<pre>tail /var/log/mail.log</pre>
for something like
<pre>Sep 29 01:41:24 mailserver cyrus/imap[18380]: accepted connection<br/>Sep 29 01:41:28 mailserver cyrus/imap[18380]: login: localhost [127.0.0.1] rod plaintext User logged in</pre>
</li><li> <b>smtptest</b> - Do the same with <code>smtptest</code>. Stop here and get things working before going on.</li></ol>
<h2 id="title_9" >Open the Firewall</h2>
At this point the server has no open relays and only on usable SMTP or IMAP login (albeit with no mailbox!), so let's open the firewalled ports for access. 
<pre>sudo ufw allow smtp<br/>sudo ufw allow pop3<br/>sudo ufw allow pop3s<br/>sudo ufw allow imap<br/>sudo ufw allow imaps<br/>sudo ufw status</pre>
Now, I recommend a reboot, to see if everything comes up clean, and an <code>imtest</code> from a remote machine:
<pre>sudo reboot</pre>
<h2 id="title_10" >Epilogue</h2>
You've got a fully configured mail server, but you can't start sending/receiving email yet: Cyrus does not have any mailboxes. (Well, maybe send, but not receive.) If you want to create one, use the <code>cyradm</code> program (see <code>man cyradm</code>). However, don't bother if you're going to proceed with the Web-Cyradm setup.<br />
<br />
You could stop here and just run the server like this: configure domains with a Postfix virtual map file (see <a href="http://www.postfix.org/VIRTUAL_README.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">www.postfix.org/VIRTUAL_README.html</a>), mailboxes with cyradm and logins via shell accounts. This config is not covered here, but if you made it this far, you should have no trouble figuring it out. Fyi, it worked fine for me for 5 years. One hint: you'll need a login for a "cyrus" user as an admin in cyradm.<br />
<br />
The <a href="http://morison.biz/technotes/articles/46" title="Read the article" class="article">Anti-Spam &amp; Anti-Virus Install</a> configurations should all work, even if you don't setup Web-Cyradm, though I haven't tested that config.<br />
<br />
Next up: <a href="http://morison.biz/technotes/articles/45" title="Read the article" class="article">Web-Cyradm Install</a></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Fri, 19 Feb 2010 20:36:49 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/44#comments</comments>
		<slash:comments>4</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/44</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/44</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:44</trackback:ping>
	</item>

	<item>
		<title>Ubuntu Install</title>
		<link>http://morison.biz/technotes/articles/43</link>
		<guid isPermaLink="true">http://morison.biz/technotes/articles/43</guid>
		<description>How to get a basic installation of an Ubuntu 8.04 server edition up, running, firewalled, and networked</description>
		<body xmlns="http://www.w3.org/1999/xhtml"><div class="introduction">How to get a basic installation of an Ubuntu 8.04 server edition up, running, firewalled, and networked.</div>
<ol class="1"><li> <b>Get the Ubuntu iso</b> - First step, download and burn an Ubuntu server CD. Follow the links from <a href="http://releases.ubuntu.com/8.04/" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://releases.ubuntu.com/8.04/</a> to a mirror. Be sure to get the correct <b>server</b> iso for your install, most likely the ubuntu-8.04.1-server-i386.iso (or newer release in the 8.04 series).
</li><li> <b>Ready the Hardware</b> - Get your machine ready to boot, and networked to your switch. This doc assumes you'll boot initially on a private network with DHCP, then move the box to its public static IP after the firewall is setup. <br />
<br />
You'll need a monitor and a keyboard for the install on the console (a KVM is handy for this). You don't need anything fancy, though. It will all be text screens and when your finished, the server shouldn't need the monitor. You may still need the keyboard, however: many non-server motherboards won't boot without a keyboard plugged in.
</li><li> <b>Boot the CD</b> - Be sure to do any bios configs at this point, typically configuring a hardware raid and/or setting the CD to boot before any other devices. After loading a kernel, the CD will walk you through a series of screens on the console.
</li><li> <b>Language</b> - The CD will boot into the Ubuntu install menu, and  immediately ask what language you would like to work in. Use arrow keys to select and hit return. 
<span class="center_image"><a href="http://morison.biz/technotes/images/2"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-01.png" alt="Initial Language Select"  title="Initial Language Select"http://morison.biz/></span></a><span class="image_caption">Initial Language Select</span></span>
</li><li> <b>Install Menu</b> - Select <i>Install Ubuntu Server</i> from this screen. Note the <i>Rescue a broken system</i> though, which is a valuable tool for inspecting a broken system. 
<span class="center_image"><a href="http://morison.biz/technotes/images/3"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-02.png" alt="Ubuntu Install Menu"  title="Ubuntu Install Menu"http://morison.biz/></span></a><span class="image_caption">Ubuntu Install Menu</span></span>
</li><li> <b>Choose Language</b> - After "Loading Linux Kernel" completes and the installer is loaded, you'll get another language select. In this case you'll select the default language for the server. 
<span class="center_image"><a href="http://morison.biz/technotes/images/4"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-03.png" alt="Choose Default Language"  title="Choose Default Language"http://morison.biz/></span></a><span class="image_caption">Choose Default Language</span></span>
</li><li> <b>Choose Language Pt 2</b> - Select a country. 
<span class="center_image"><a href="http://morison.biz/technotes/images/5"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-04.png" alt="Choose Country"  title="Choose Country"http://morison.biz/></span></a><span class="image_caption">Choose Country</span></span>
</li><li> <b>Keyboard layout</b> - Either let the installer detect your keyboard type or nav through the menus to select. 
<span class="center_image"><a href="http://morison.biz/technotes/images/6"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-05.png" alt="Detect Keyboard Layout"  title="Detect Keyboard Layout"http://morison.biz/></span></a><span class="image_caption">Detect Keyboard Layout</span></span>
</li><li> <b>Detect and Load</b> - The installer will now detect your hardware and load more software off the CD. 
<span class="center_image"><a href="http://morison.biz/technotes/images/7"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-06a.png" alt="Detect Hardware"  title="Detect Hardware"http://morison.biz/></span></a><span class="image_caption">Detect Hardware</span></span> 
<span class="center_image"><a href="http://morison.biz/technotes/images/8"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-06b.png" alt="Load Additional Components"  title="Load Additional Components"http://morison.biz/></span></a><span class="image_caption">Load Additional Components</span></span>
</li><li> <b>Hostname</b> - Enter the hostname, not including the domain part, in this case "mailserver". 
<span class="center_image"><a href="http://morison.biz/technotes/images/9"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-07.png" alt="Set Host Name"  title="Set Host Name"http://morison.biz/></span></a><span class="image_caption">Set Host Name</span></span>
</li><li> <b>Time Zone</b> - Choose the time zone this server will run in. 
<span class="center_image"><a href="http://morison.biz/technotes/images/10"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-08.png" alt="Select Time Zone"  title="Select Time Zone"http://morison.biz/></span></a><span class="image_caption">Select Time Zone</span></span>
</li><li> <b>Partition</b> - After detecting disks, the installer will offer to guide you through partitioning. If you're not experienced with partitioning, take the simple, default, single partition+swap setup (shown here.) Experienced users may setup LVM, software RAID and other customizations in the following few screens. For the simple case, choose "Guided - use entire disk" 
<span class="center_image"><a href="http://morison.biz/technotes/images/11"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-09.png" alt="Partition Disks"  title="Partition Disks"http://morison.biz/></span></a><span class="image_caption">Partition Disks</span></span>
</li><li> <b>Guided Partitioning Step 1</b> - Select the disk to partition. If you have a single disk, that's all there is to select.  
<span class="center_image"><a href="http://morison.biz/technotes/images/12"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-10.png" alt="Select Disk"  title="Select Disk"http://morison.biz/></span></a><span class="image_caption">Select Disk</span></span>
</li><li> <b>Guided Partitioning Step 2</b> - Accept the default partition and select "Yes". This setup gives a swap 3x the size of physical RAM and the remainder on a single partition, "http://morison.biz/" (read that "slash", the root of the Linux file system.) 
<span class="center_image"><a href="http://morison.biz/technotes/images/13"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-11.png" alt="Write Partitions to Disk"  title="Write Partitions to Disk"http://morison.biz/></span></a><span class="image_caption">Write Partitions to Disk</span></span>
</li><li> <b>Partition &amp; Install</b> - The installer will proceed with the partitioning and base package installation. You'll have time to a get coffee while it installs.<br />
<br />
<span class="center_image"><a href="http://morison.biz/technotes/images/14"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-12a.png" alt="Partitions Formatting"  title="Partitions Formatting"http://morison.biz/></span></a><span class="image_caption">Partitions Formatting</span></span> 
<span class="center_image"><a href="http://morison.biz/technotes/images/15"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-12b.png" alt="Installing System"  title="Installing System"http://morison.biz/></span></a><span class="image_caption">Installing System</span></span>
</li><li> <b>Setup Users</b> - Enter the full name of the "initial" user doing the install, then a login ID, then a password. Access to root, i.e., the admin account, will be on a command by command basis via the sudo program. Even during installations, it's preferred to take root credentials only as needed, and not be logged in for long stretches as root. 
<span class="center_image"><a href="http://morison.biz/technotes/images/16"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-13a.png" alt="User Full Name"  title="User Full Name"http://morison.biz/></span></a><span class="image_caption">User Full Name</span></span> 
<span class="center_image"><a href="http://morison.biz/technotes/images/17"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-13b.png" alt="User ID"  title="User ID"http://morison.biz/></span></a><span class="image_caption">User ID</span></span> 
<span class="center_image"><a href="http://morison.biz/technotes/images/18"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-13c.png" alt="User Password"  title="User Password"http://morison.biz/></span></a><span class="image_caption">User Password</span></span> 
<span class="center_image"><a href="http://morison.biz/technotes/images/19"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-13d.png" alt="User Password Confirm"  title="User Password Confirm"http://morison.biz/></span></a><span class="image_caption">User Password Confirm</span></span>
</li><li> <b>Configure apt-get</b> - The program apt-get will install Ubuntu software packages, usually from an Ubuntu fileserver or mirror. It is the primary and preferred way to install and update software on the system. If you need to go through an http proxy to browse, enter the info here so apt-get can do the same. Most users can leave this blank. 
<span class="center_image"><a href="http://morison.biz/technotes/images/20"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-14.png" alt="Configure apt-get Proxy"  title="Configure apt-get Proxy"http://morison.biz/></span></a><span class="image_caption">Configure apt-get Proxy</span></span>
</li><li> <b>Software Selection</b> - The next screen will ask what services should be installed. We'll only install the OpenSSH server at this point, for command line access over a network. The remaining packages we'll install with apt-get once the system is up, running, and networked. Arrow down to the OpenSSH selection, hit space, tab to continue, and hit return. 
<span class="center_image"><a href="http://morison.biz/technotes/images/21"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-15.png" alt="Install OpenSSH"  title="Install OpenSSH"http://morison.biz/></span></a><span class="image_caption">Install OpenSSH</span></span>
</li><li> <b>Installation Complete</b> - Hit Continue to reboot the system and get a login prompt. 
<span class="center_image"><a href="http://morison.biz/technotes/images/22"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-16.png" alt="Installation Complete"  title="Installation Complete"http://morison.biz/></span></a><span class="image_caption">Installation Complete</span></span> 
<span class="center_image"><a href="http://morison.biz/technotes/images/23"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-17.png" alt="Login Prompt"  title="Login Prompt"http://morison.biz/></span></a><span class="image_caption">Login Prompt</span></span>
</li><li> <b>Login</b> - Login with the user credentials created previously. 
</li><li> <b>Config ssh</b> - There are quite a few scanners out there that try to guess passwords for user IDs like "guest", "test", "root", "www", etc. Because all of these that I've encountered work the standard ssh port, 22, I make it a practice to change ssh to a high numbered port. We'll use 9999. You can choose your own, but keep it above 1023 (see <a href="http://en.wikipedia.org/wiki/Well_known_ports)." title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://en.wikipedia.org/wiki/Well_known_ports).</a> Or, you can skip this step and keep it at the standard port 22.
<pre>sudo vi /etc/ssh/sshd_config<br/>[sudo] password for rod:</pre>
The sudo program will run the command given on the same line as the root user. As configured on Ubuntu server, sudo requests the invoking user's password, not root's password. This arrangement is a good thing, btw, making it easier to give or revoke root privs, compared to handing out the root password. Also, sudo can fine grain access to specific commands by user ID, group, etc. For more information, <code>man sudo</code> and inspect the settings in <code>/etc/sudoers</code> (for which you will need...sudo.)
<span class="center_image"><a href="http://morison.biz/technotes/images/24"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-19.png" alt="sudo vi /etc/ssh/sshd_config"  title="sudo vi /etc/ssh/sshd_config"http://morison.biz/></span></a><span class="image_caption">Sudo vi /etc/ssh/sshd_config</span></span>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> It's assumed you can edit text files. The vi editor is used in these examples; pico is also installed, and is a little more intuitive for those that didn't grow up with vi. Run <code>man vi</code> or <code>man pico</code> or google around for more info. </p>
</li><li> <b>Set the Port</b> - Edit the line <code>Port 22</code> and change the 22 to your new ssh port. Save and exit. 
<span class="center_image"><a href="http://morison.biz/technotes/images/25"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-20.png" alt="Change ssh Port"  title="Change ssh Port"http://morison.biz/></span></a><span class="image_caption">Change ssh Port</span></span>
</li><li> <b>Restart</b> the ssh server.
<pre>sudo /etc/init.d/ssh restart</pre>
</li><li> <b>Setup the Firewall</b> - 
<span class="right_image"><a href="http://morison.biz/technotes/images/26"><span><img src="http://morison.biz/technotes/images/article/43/thumbs/UbuntuInstall-21.png" alt="ufw init"  title="ufw init"http://morison.biz/></span></a><span class="image_caption">Ufw init</span></span>Now we'll configure the Ubuntu ufw firewall...it's easy to use and has just enough configuration for this mail server setup. For docs on ufw and a list of more powerful firewall options, see the <a href="http://doc.ubuntu.com/ubuntu/serverguide/C/firewall.html" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">Ubuntu Server Manual Firewall section</a>. We'll start ufw in it's most restrictive form (block everything) and then open the ssh port configured above. 
<pre>sudo ufw default deny<br/>sudo ufw enable<br/>sudo ufw allow 9999<br/>sudo ufw status</pre>
</li><li> <b>Config Static IP</b> - Assuming you installed on a net with DHCP, you should see something like the following when you type <code>/sbin/ifconfig</code>:
<pre>rod@mailserver:~$ /sbin/ifconfig<br/>eth0      Link encap:Ethernet  HWaddr 00:0c:29:a5:2f:f1  <br/>          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0<br/>          inet6 addr: fe80::20c:29ff:fea5:2ff1/64 Scope:Link<br/>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br/>          RX packets:1586 errors:0 dropped:0 overruns:0 frame:0<br/>          TX packets:54 errors:0 dropped:0 overruns:0 carrier:0<br/>          collisions:0 txqueuelen:1000 <br/>          RX bytes:138577 (135.3 KB)  TX bytes:7227 (7.0 KB)<br/>          Interrupt:16 Base address:0x2000 <br/><br/>lo        Link encap:Local Loopback  <br/>          inet addr:127.0.0.1  Mask:255.0.0.0<br/>          inet6 addr: ::1/128 Scope:Host<br/>          UP LOOPBACK RUNNING  MTU:16436  Metric:1<br/>          RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br/>          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br/>          collisions:0 txqueuelen:0 <br/>          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)</pre>
That means your assigned address is 192.168.1.101. (If you're not seeing that, then I'm note sure how you got this far!  <img src="http://morison.biz/technotes/skins/images/smileys/winkgrin.gif" alt="" />  ) Fyi <code>sudo ethtool eth0</code> is handy and will tell you if your adapter detects a link to the switch.) 
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> Skip or modify the rest of this step if your building an experimental system that will stay on your private network</p>
Edit the network config file
<pre>sudo vi /etc/network/interfaces</pre>
and edit the eth0 section from the word "dhcp" so that it reads
<pre>iface eth0 inet static<br/>        address xx.xx.xx.xx<br/>        netmask yy.yy.yy.yy<br/>        gateway zz.zz.zz.zz</pre>
replacing xx.xx.xx.xx with your static IP, yy.yy.yy.yy with the netmask, and zz.zz.zz.zz with the gateway IP (these should have come with the static.)
</li><li> <b>Edit DNS</b>
<p class="note"><img src="http://morison.biz/technotes/skins/technotes2/icons/codes/note.gif" width="10" height="10" alt="" /> Skip this step if you're staying on the DHCP provided address. </p>
<pre>sudo vi /etc/resolv.conf</pre>
to read
<pre>search mydomain<br/>nameserver nameserverIP1<br/>nameserver nameserverIP2</pre>
where mydomain is your domain name, e.g., foobar.com, and nameserver1 and nameserver2 are two namerserver IP addresses, usually given by your access provider, along with the static IP.
</li><li> <b>Turn on the Static IP</b> - Run
<pre>sudo ifdown eth0 ; sudo ifup eth0</pre>
to pick up the new settings. 
</li><li> <b>Ping-Check Your Work</b> - At this point, you'll have to recable (and perhaps move) your server outside your private IP router (or put it in the router DMZ.) Check for link status, and try pinging a few things.
<pre>sudo ethtool eth0</pre>
and you should see
<pre>Settings for eth0:<br/>        Current message level: 0x00000007 (7)<br/>        Link detected: yes</pre>
Then, ping the gateway (from /etc/network/interfaces) and a DNS server (from /etc/resolv.conf), hitting control-C when you've seen enough
<pre>ping 64.81.45.2<br/>PING 64.81.45.2 (64.81.45.2) 56(84) bytes of data.<br/>64 bytes from 64.81.45.2: icmp_seq=1 ttl=62 time=27.2 ms<br/>64 bytes from 64.81.45.2: icmp_seq=2 ttl=62 time=33.0 ms<br/>64 bytes from 64.81.45.2: icmp_seq=3 ttl=62 time=69.1 ms<br/><br/>--- 64.81.45.2 ping statistics ---<br/>3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br/>rtt min/avg/max/mdev = 27.290/43.133/69.109/18.515 ms</pre>
Finally, try pinging Google, which will verify that your /etc/resolv.conf settings are good
<pre>ping google.com<br/>PING google.com (64.233.187.99) 56(84) bytes of data.<br/>64 bytes from jc-in-f99.google.com (64.233.187.99): icmp_seq=1 ttl=247 time=97.5 ms<br/>64 bytes from jc-in-f99.google.com (64.233.187.99): icmp_seq=2 ttl=247 time=96.2 ms<br/>64 bytes from jc-in-f99.google.com (64.233.187.99): icmp_seq=3 ttl=247 time=98.3 ms<br/><br/>--- google.com ping statistics ---<br/>3 packets transmitted, 3 received, 0% packet loss, time 2003ms<br/>rtt min/avg/max/mdev = 96.248/97.380/98.370/0.943 ms</pre>
</li><li> <b>Ntp</b> - Ok, one last thing and we've got a nicely stocked, vanilla Ubuntu server: an NTP daemon. 
<div class="sidebar_box" id="sidebar_1" >
<h3></h3>
<div>It's quite important that mail servers (all servers, really) have very accurate time. When you need to debug across machines, verify mail headers...and computer clocks <i>will</i> drift. Plus, you really want to be able to say, "You can trust the datestamps in my mail headers" at the next party you go to.  <img src="http://morison.biz/technotes/skins/images/smileys/rolleyes.gif" alt="" />  </div></div>
The NTP daemon on your will check regularly with a NTP server that is tied into regional or international standard time servers.  See <a href="http://www.ntp.org/ntpfaq/NTP-a-faq.htm" title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.ntp.org/ntpfaq/NTP-a-faq.htm</a> if you're interested.<br />
<br />
Run
<pre>sudo apt-get install ntp</pre>
and you should see
<pre>Reading package lists... Done<br/>Building dependency tree       <br/>Reading state information... Done<br/>Suggested packages:<br/>  ntp-doc<br/>The following NEW packages will be installed:<br/>  ntp<br/>0 upgraded, 1 newly installed, 0 to remove and 22 not upgraded.<br/>Need to get 432kB of archives.<br/>After this operation, 1069kB of additional disk space will be used.<br/>Get:1 http://us.archive.ubuntu.com hardy/main ntp 1:4.2.4p4+dfsg-3ubuntu2 [432kB]<br/>Fetched 432kB in 1s (220kB/s)<br/>Selecting previously deselected package ntp.<br/>(Reading database ... 15320 files and directories currently installed.)<br/>Unpacking ntp (from .../ntp_1%3a4.2.4p4+dfsg-3ubuntu2_i386.deb) ...<br/>Setting up ntp (1:4.2.4p4+dfsg-3ubuntu2) ...<br/> * Starting NTP server ntpd                                              [ OK ]</pre>
</li><li> <b>Update NTP Servers</b> - It's highly advisable to configure ntp to talk to several regional servers. First, visit <a href="http://www.pool.ntp.org/," title="Browse in a new window" class="external" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">http://www.pool.ntp.org/,</a> click on your region (should be top right of the page, under Active Servers). At the top of the page you should see something that begins, "To use this pool zone, add the following to your ntp.conf file:". Copy or type that text into /etc/ntp.conf. That is, run
<pre>sudo vi /etc/ntp.conf</pre>
and a few lines down, where you see <code>server ntp.ubuntu.com</code>, remove the Ubuntu server and replace it with your regional pool servers. For North America, the first dozen or so lines of the /etc/ntp.conf file looks like
<pre># /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help<br/><br/>driftfile /var/lib/ntp/ntp.drift<br/><br/><br/># Enable this if you want statistics to be logged.<br/>#statsdir /var/log/ntpstats/<br/><br/>statistics loopstats peerstats clockstats<br/>filegen loopstats file loopstats type day enable<br/>filegen peerstats file peerstats type day enable<br/>filegen clockstats file clockstats type day enable<br/><br/><br/># You do need to talk to an NTP server or two (or three).<br/>server 0.north-america.pool.ntp.org<br/>server 1.north-america.pool.ntp.org<br/>server 2.north-america.pool.ntp.org<br/>server 3.north-america.pool.ntp.org</pre>
</li><li> <b>Restart ntp</b>
<pre>sudo /etc/init.d/ntp restart</pre></li></ol>
That's it! You've got a nice, clean Ubuntu server, ready to rock-n-roll some email.<br />
<br />
Next up: <a href="http://morison.biz/technotes/articles/44" title="Read the article" class="article">Postfix &amp; Cyrus Install</a></body>
		<dc:creator>rod</dc:creator>
		<pubDate>Tue, 30 Sep 2008 04:44:30 GMT</pubDate>
		<comments>http://morison.biz/technotes/articles/43#comments</comments>
		<slash:comments>0</slash:comments>
		<wfw:comment>http://morison.biz/technotes/comments/post.php/article/43</wfw:comment>
		<wfw:commentRss>http://morison.biz/technotes/comments/feed.php/article/43</wfw:commentRss>
		<trackback:ping>http://morison.biz/technotes/links/trackback.php?anchor=article:43</trackback:ping>
	</item>

</channel>
</rss>