<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Penguins-On-Hudson &#187; HowTo</title>
	<atom:link href="http://codefix.wordpress.com/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://codefix.wordpress.com</link>
	<description>Linux &#38; F.O.S.S. in the Hudson River Valley.</description>
	<lastBuildDate>Sat, 01 Nov 2008 21:45:07 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='codefix.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/904cee70020c986d4c7351c3f0a73f32?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Penguins-On-Hudson &#187; HowTo</title>
		<link>http://codefix.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codefix.wordpress.com/osd.xml" title="Penguins-On-Hudson" />
		<item>
		<title>OpenSSH: Environmental Override</title>
		<link>http://codefix.wordpress.com/2008/11/01/openssh-environmental-override/</link>
		<comments>http://codefix.wordpress.com/2008/11/01/openssh-environmental-override/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 21:45:07 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Case Study]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=254</guid>
		<description><![CDATA[prerequisite concepts: prelude, basic configuration
This post is as much about customizing the root shell as it is about SSH environment variables, but I&#8217;m adding this to my OpenSSH collection because it&#8217;s applicable to  any user.
I occasionally work on servers where, for a variety of reasons, I share an account with one or more other [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=254&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:right;"><em>prerequisite concepts: <a href="http://blog.penguins-on-hudson.com/2008/09/25/openssh-prelude/">prelude</a>, <a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">basic configuration</a></em></p>
<p>This post is as much about customizing the root shell as it is about SSH environment variables, but I&#8217;m adding this to my <a href="http://blog.penguins-on-hudson.com/2008/09/25/openssh-prelude/">OpenSSH collection</a> because it&#8217;s applicable to <a href="http://openssh.org"><img src="http://codefix.files.wordpress.com/2008/10/puffy-armed.png?w=200&#038;h=170" alt="" title="puffy-armed" width="200" height="170" class="alignright size-full wp-image-154" /></a> any user.</p>
<p>I occasionally work on servers where, for a variety of reasons, I share an account with one or more other users; this is almost always suboptimal, but it does happen nonetheless. Over time I&#8217;ve grown somewhat partial to <a href="http://www.zsh.org">zShell</a>, so one method I&#8217;ve used is to log in to a default shell, usually bash, then run <span class="code">zsh</span>.<span id="more-254"></span></p>
<p>Even on server&#8217;s where I am the sole administrator, I usually don&#8217;t change the default shell&#8211; not so much because of days gone by when doing such a thing would break boot scripts &amp; such, but because I try to practice the good habit of logging in as a normal user and using sudo for escalated privileges.</p>
<p>Eventually I struck upon the idea to have some code in the shell init script (e.g. $HOME/.bash_profile) switch to the shell of my choosing automatically as I log in. What I came up with looks something like this:</p>
<pre>if [ -n "$CDFX_SHELL" ]; then
    tty -s &amp;&amp; exec $CDFX_SHELL
fi</pre>
<p>Briefly this code says, &#8220;if $CDFX_SHELL isn&#8217;t empty and the tty program says we&#8217;re connected to a terminal (on STDIN), then replace this shell by running the command in $CDFX_SHELL without creating a new process.&#8221;</p>
<p>Readers familiar with shell initialization may recognize potentially unnecessary checks in this example but this avoids having to delve into the differences between shell sessions which are <em>interactive</em>, <em>login</em>, both, or neither, as well as how this relates to scp and rsync. Also noteworthy are the checks which should be in the code before it&#8217;s used on a production server, such as verifying that $CDFX_SHELL specifies a valid shell. This isn&#8217;t intended to be cut-n-paste code.</p>
<p>Two steps are necessary for this to work: obviously $CDFX_SHELL must be set in the local environment for SSH to have anything to pass to the server, but less obviously the server must be configured to allow this variable to be set. This can be configured in the sshd config file (e.g. /etc/ssh/sshd_config) by adding this line:</p>
<p><code>AcceptEnv CDFX_SHELL</code></p>
<p>I prefer this method over those which require enabling PermitUserEnvironment because it&#8217;s less prone to unintended side-effects, as noted in the man page. In addition to (or in lieu of) using exec to switch shells, this method could also be used to set custom environments in the same shell, for different users or the same user, anytime it&#8217;s useful to have login behavior change based upon variables set in the SSH client.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/254/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=254&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/11/01/openssh-environmental-override/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2008/10/puffy-armed.png" medium="image">
			<media:title type="html">puffy-armed</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenSSH: Proxy Connections</title>
		<link>http://codefix.wordpress.com/2008/10/17/openssh-proxy-connections/</link>
		<comments>http://codefix.wordpress.com/2008/10/17/openssh-proxy-connections/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 15:00:38 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=200</guid>
		<description><![CDATA[prerequisite concepts: prelude, basic configuration, port forwarding
Network address translation (NAT) is a very common method of providing secure access to hosts on a private network.  Given the limited amount of IPv4 addresses, computer networks with relatively few, very few, and even a single public IP address are common. A typical small business customer of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=200&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:right;"><em>prerequisite concepts: <a href="http://blog.penguins-on-hudson.com/2008/09/25/openssh-prelude/">prelude</a>, <a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">basic configuration</a>, <a href="http://blog.penguins-on-hudson.com/2008/10/16/open-ssh-port-forwarding/">port forwarding</a></em></p>
<p><a href="http://en.wikipedia.org/wiki/Network_address_translation">Network address translation</a> (NAT) is a very common method of providing secure access to hosts on a <a href="http://en.wikipedia.org/wiki/Private_network">private network</a>. <a href="http://openssh.org"><img src="http://codefix.files.wordpress.com/2008/10/puffy-armed.png?w=200&#038;h=170" alt="" title="puffy-armed" width="200" height="170" class="alignright size-full wp-image-154" /></a> Given the limited amount of <a href="http://en.wikipedia.org/wiki/IP_address_starvation">IPv4 addresses</a>, computer networks with relatively few, very few, and even a single public IP address are common. A typical small business customer of my <a href="http://codefix.net">consulting practice</a> has one or more Linux servers on an office network protected by a firewall. The following is a close look at Example Industries, the theoretical owners of example.com; this customer receives support for two Linux servers, a mail server and a PBX, but only one public IP address between them. Through NAT, public services (namely mail and VoIP) on both servers are accessible via example.com. This works well for inbound mail and phone calls, which only need to access one or the other host, but SSH access is the lifeblood of remote system administration, and there&#8217;s the rub&#8211; when I enter <span class="code">ssh example.com</span> I land at the mail server. SSH access to the PBX would seemingly threaten to litter my command line with unsightly extra characters, if not subsequent commands outright.<br />
<span class="highlight"><br />
My carpals are tunneled enough, I don&#8217;t want to type more than <span class="code">ssh mail</span> and <span class="code">ssh pbx</span> to access these servers, and while I&#8217;m at it I want to have scripted log-ins as well&#8211; securely, not those namby-pamby no-password keys. In fact, I don&#8217;t even want to have private keys on either server.</span><br />
<span class="highlight"><br />
Fear not! With the power of OpenSSH, I can fix this.<br />
</span><span id="more-200"></span><br />
Recipes for SSH proxies are like homespun cure-alls: few do much good and some are actually harmful. As indicated in my introductory rant, I have a few criteria for this sort of thing:</p>
<ul>
<li>No interactive passwords.</li>
<li>No password-less keys.</li>
<li>No private keys on servers.</li>
<li>Avoid command line options.</li>
<li>Demur scripts.</li>
</ul>
<p>Previous installments in this series have intentionally focused on declarations which will help define my Example Industries SSH client configuration; here&#8217;s the file so far:<br />
<code># /home/garrison/.ssh/config<br />
&#160;<br />
# Global Options<br />
Host *<br />
ForwardAgent yes<br />
&#160;<br />
Host mail<br />
HostName example.com<br />
&#160;<br />
Host pbx<br />
HostName example.com<br />
LocalForward 8080 localhost:80<br />
LocalForward 3306 localhost:3306</code></p>
<p>At this point <span class="code">ssh mail</span> and <span class="code">ssh pbx</span> are functionally equivalent in that both land me on the mail server, and I want forwarded access to <span class="code">pbx</span>&#8217;s web configuration and database but I end up with webmail and mail user database (which I can access without port forwarding). While I can certainly connect to <span class="code">pbx</span> once I&#8217;m in <span class="code">mail</span>, I must specify it&#8217;s internal address (<span class="code">ssh 192.168.1.20</span>) and the services I require will not be forwarded to my workstation. What I need is a way to tell SSH to bypass <span class="code">mail</span> and connect me directly to <span class="code">pbx</span>.</p>
<p>Rubbish. In life, particularly in technology, we often confound our challenges by mischaracterizing the requirements of a solution as I just have. It is no coincidence that my most successful customers are also the ones who make use of my ability to solve problems, rather than simply implementing solutions. Often the most challenging part of a solution is correctly stating the problem. What I really need is just for <span class="code">ssh pbx</span> to connect me to <span class="code">pbx</span> and forward my ports; I don&#8217;t really care whether <span class="code">mail</span> is bypassed or not, so long as it stays out of my way.</p>
<p>As it turns out, the solution I favor does not bypass the gateway host (<span class="code">mail</span>) at all, but uses it as a proxy for my connection to <span class="code">pbx</span>. With the addition of a <span class="code">ProxyCommand</span> directive to my SSH config, I can achieve all my objectives.</p>
<p>The <span class="code">ProxyCommand</span> directive is a subtle beast, and my early attempts to use it were unsuccessful. At the time I was doing something similar on the command line: <span class="code">ssh -t example.com ssh 192.168.1.20</span> Because I initially hoped to &#8220;do the same thing in the config file&#8221; I mistakenly assumed that <span class="code">ProxyCommand</span> would allow my to connect to mail and immediately fire off a connection to pbx; <span class="code">LocalCommand</span> behaves this way but doesn&#8217;t allow me to accomplish what I can with <span class="code">ProxyCommand</span>.<br />
After a few unsuccessful syntax variations, I began to suspect that I might have the wrong idea about this directive.</p>
<p>When I eventually sorted out the correct syntax, I knew I had the wrong notion because I had no clue why one version worked and the others did not. Richard Silverman, one of the authors of the <a href="http://www.snailbook.com/">snail book</a> was kind enough to set me straight. He explained:</p>
<blockquote><p>ProxyCommand specifies a program which the SSH client will use to contact the remote SSH server.  Instead of opening a TCP connection, it runs this program and uses its stdin/stdout as the communications channel.</p></blockquote>
<p>I then understood that with <span class="code">ProxyCommand</span> in play, SSH expects the command it executes to provide the TCP connection between <span class="code">mail</span> and <span class="code">pbx</span>; <a href="http://en.wikipedia.org/wiki/Netcat">netcat</a>, a phenomenally <a href="http://sectools.org/tools2000.html">useful tool</a>, was designed for just this sort of task:</p>
<p><code>ProxyCommand ssh example.com nc -v %h %p</code></p>
<p>Adding this directive to the <span class="code">Host pbx</span> section of my config gets the whole proxy business out of my way and I can connect with just <span class="code">ssh pbx</span>; tho forwarded HTTP and MySQL connections are just the beginning. I can use scp, sftp, FuseSSH, sshfs or anything built on SSH just as if <span class="code">pbx</span> had a public IP. One more example:</p>
<p><code>rsync -Hav pbx:/usr/stuff backup:/archive</code></p>
<p>I often use such a command to transfer data from a machine with no public IP address to a backup server which also has no public IP and lives on another private network in a different town, state, or country. This is all done with <span class="code">ProxyCommand</span> directives, over secure SSH connections, and most importantly, with no special command line syntax. What could be easier?</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=200&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/10/17/openssh-proxy-connections/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2008/10/puffy-armed.png" medium="image">
			<media:title type="html">puffy-armed</media:title>
		</media:content>
	</item>
		<item>
		<title>Open SSH: Port Forwarding</title>
		<link>http://codefix.wordpress.com/2008/10/16/open-ssh-port-forwarding/</link>
		<comments>http://codefix.wordpress.com/2008/10/16/open-ssh-port-forwarding/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 20:59:46 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=159</guid>
		<description><![CDATA[prerequisite concepts: prelude, basic configuration
Port forwarding  is a versatile feature which informs several popular concepts, including X Forwarding and tunneling which are briefly explained below; more advanced port magic will be addressed elsewhere.
X Forwarding
At the end of the previous installment of this series is an example SSH client configuration file, usually located at ~/.ssh/conf; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=159&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:right;"><em>prerequisite concepts: <a href="http://blog.penguins-on-hudson.com/2008/09/25/openssh-prelude/">prelude</a>, <a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">basic configuration</a></em></p>
<p><a href="http://en.wikipedia.org/wiki/Port_forwarding">Port forwarding</a> <a href="http://codefix.files.wordpress.com/2008/10/puffy-armed.png"><img class="alignright size-full wp-image-154" title="puffy-armed" src="http://codefix.files.wordpress.com/2008/10/puffy-armed.png?w=200&#038;h=170" alt="" width="200" height="170" /></a> is a versatile feature which informs several popular concepts, including X Forwarding and tunneling which are briefly explained below; more advanced port magic will be addressed elsewhere.</p>
<p><strong>X Forwarding</strong><br />
At the end of the <a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">previous installment</a> of this series is an example SSH client configuration file, usually located at <span class="code">~/.ssh/conf</span>; a more complete description of the global declarations shown was deferred until this section, where they are more relevant.<span id="more-159"></span><br />
<code># global declarations<br />
</code>This line is a comment and while it is ignored by SSH, it is very helpful to use comments and white space to maximize readability, and maintainability.<br />
<code>Host *</code>As <a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">previously stated</a>, Host declarations define the context of all following lines until the next Host declaration. Because the &#8216;*&#8217; will match any host, these declarations will be applied to all hosts&#8211; unless overridden by a later declaration or a command line option.<br />
<code>ForwardAgent yes</code>The key agent allows a user to store one or more authenticated keys in memory, enabling dual key authentication; this is sometimes (incorrectly) referred to as passwordless authentication, but a password check is still required to load the key into the agent. Agent forwarding allows one not only to rely on keys instead of passwords to connect to a remote server, but to use the same agent to connect to a third host and so on as long as the keys are recognized and ForwardAgent is enabled on each host.<br />
<code>ForwardX11 yes</code>This declaration turns on port forwarding for <a href="http://en.wikipedia.org/wiki/X_windows">X Windows</a> authentication; briefly put, this allows an X session (i.e. the active GUI environment) on a Linux workstation to interact with X Windows on a remote host using an encrypted tunnel. The practical benefit is that programs on a remote host needing or allowing a graphic interface may use one provided by the client. The canonical example is that I run <span class="code">xclock</span> on a remote server and the clock appears on my screen.</p>
<p><strong>Tunneling</strong><br />
X forwarding may be fun, but port forwarding has many more practical uses. Suppose you need to connect to a web application on, perhaps FreePBX to configure a Linux PBX, but you cannot connect directly because port 80 is blocked&#8211; there are a few reasons why this might occur but port forwarding can work equally well in all likely scenarios.</p>
<p>If you log in to the remote host with <code>ssh -L 8080:localhost:80 joe.telco@pbx.example.com</code> SSH will create an encrypted tunnel between port 8080 on your workstation and port 80 on the server, ergo you can now get to the web app by pointing your browser to <a href="http://localhost:8080">http://localhost:8080</a>. Because the connection is tunneled through SSH, it works even if port 80 is restricted by IP address or an interceding router, firewall, or cable modem; because of SSH&#8217;s strong encryption, this technique also provides a secure connection to servers which do not offer SSL.</p>
<p>Many users mistakenly assume that the localhost in the preceding command is the one referenced in the subsequent URL; in fact, the given example is connecting (client) localhost:8080 to (server) localhost:80 and could be entered as:<br />
<code class="nowrap">ssh -L <span class="teal">localhost:8080</span>:<span class="purple">pbx.example.com:80</span> joe.telco@pb»</code><br />
The notable concept is that the latter <span class="purple">host:port</span> pair is evaluated on the remote host, meaning it&#8217;s a bit like saying:</p>
<div style="text-align:center;">&#8220;<em>connect my</em> <span class="teal">self:8080</span> <em>to your</em> <span class="purple">self:80</span>&#8220;</div>
<p><code>ssh -L <span class="sky">localhost:8080</span>:localhost:80 joe.telco@pbx.exam»<br />
ssh -L <span class="sky">192.168.1.7:8080</span>:localhost:80 joe.telco@pbx.ex»<br />
ssh -L <span class="sky">*:8080</span>:localhost:80 joe.telco@pbx.example.com<br />
</code>The explicit use of localhost in the first of the preceding examples restricts listening port 8080 for local use only; in contrast, the second example binds the port to a specific network interface, and other users on the network may use the forwarded port at the specified IP address; the last example avails the port on all interfaces. If the bind address is not specified, the port is bound to the loopback address unless <span class="code">GatewayPorts</span> is enabled, wherein the wildcard address issued.</p>
<p>The config file is the place for complexity, and the following example specifies that connections to pbx.example.com should be made as user joe.telco, and forwarded HTTP and MySQL connections should be available on all interfaces using the specified ports.<br />
<code>Host pbx<br />
HostName pbx.example.com<br />
GatewayPorts yes<br />
User joe.telco<br />
LocalForward 8080 localhost:80<br />
LocalForward 3306 localhost:3306<br />
</code>As <a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">previously illustrated</a>, this simplifies the command line syntax such that in lieu of:<br />
<code>ssh -g -u joe.telco -L 8080:localhost:80 \<br />
-L 3306:localhost:3306 pbx.example.com</code>one need only enter:<br />
<code>ssh pbx</code>Much more information on the port forwarding capabilities of SSH are available in the <a href="http://en.wikipedia.org/wiki/Man_pages">man pages</a> as well as previously cited sources; however, the examples here lay the foundation for the next installment of this OpenSSH series: Proxy Connections.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/159/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=159&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/10/16/open-ssh-port-forwarding/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2008/10/puffy-armed.png" medium="image">
			<media:title type="html">puffy-armed</media:title>
		</media:content>
	</item>
		<item>
		<title>I have seen the light.</title>
		<link>http://codefix.wordpress.com/2008/10/04/i-have-seen-the-light/</link>
		<comments>http://codefix.wordpress.com/2008/10/04/i-have-seen-the-light/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 20:29:10 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Case Study]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Telephony]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=138</guid>
		<description><![CDATA[Having discovered the advantages of á la carte VoIP pricing, I pondered how to extrapolate my experience for general discussion while avoiding the pitfalls of interpolation and abridgement. The Reference Book of Rates, Price Indices, and Household Expenditures for Telephone Service published by the FCC&#8217;s Wireline Competition Bureau provides a rough estimate of wireline telephone [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=138&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Having discovered the advantages of á la carte VoIP pricing, I pondered how to extrapolate my experience for general discussion while avoiding the pitfalls of interpolation and abridgement.<a href="http://codefix.files.wordpress.com/2008/10/voicemeup-invoice.png"><img class="alignright size-medium wp-image-147" title="voicemeup-invoice" src="http://codefix.files.wordpress.com/2008/10/voicemeup-invoice.png?w=210&#038;h=145" alt="" width="210" height="145" /></a> The <a href="http://hraunfoss.fcc.gov/edocs_public/attachmatch/DOC-284934A1.pdf">Reference Book of Rates, Price Indices, and Household Expenditures for Telephone Service</a> published by the FCC&#8217;s <a href="http://www.fcc.gov/wcb/">Wireline Competition Bureau</a> provides a rough estimate of wireline telephone expenses averaging $45 per month in 2007, based on market research by TNS Telecoms. This isn&#8217;t too far from my own experience with residential VoIP plans which have tended to average about $35 monthly, including additional fees and charges, which can be significant: on BroadVoice&#8217;s &#8220;Unlimited World&#8221; plan, for example,  &#8220;Taxes &amp; Surcharges&#8221; account for about 35% of the monthly total. Based on these data, I use an estimated $35-$45 for generic comparison of monthly residential phone bills, or an average average of $40. As I designed our current, á la carte plan, I surmised that after discounting <a href="http://codefix.net/">business use</a>, the residential remainder was unlikely to ever exceed $30 in a single month. As the plan took shape, however, I realized that intelligent planning could lower that even further; somewhere in the neighborhood of a $20 monthly average would certainly exemplify what custom VoIP plans can offer, and half the average isn&#8217;t a bad talking point. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <span id="more-138"></span></p>
<p>Though less obvious, another great feature of á la carte or &#8220;on demand&#8221; plans is scalability, if I suddenly find myself needing to host frequent call-in conference calls between a customer, their overseas manufacturing division, regional sales reps, and myself, the only change I&#8217;ll see on my invoices will be in usage. I am not aware of any &#8220;unlimited&#8221; residential plans which offer unlimited channels (simultaneous callers). With currently just three phone numbers, my setup is small enough, and with just enough complexity to provide a good example.</p>
<p>I use one number for my consulting, which has separate extensions, voice mail, etc.; I have a fax number for the <a href="http://en.wikipedia.org/wiki/Luddite">luddite</a> crowd, and a home number associated with a family voice mail, options for the caller to forward the call to my wife&#8217;s or my mobile phone, and a ring group which includes a line in my office. I&#8217;ll use an even usage split for comparison; for although <a href="http://codefix.net/">Codefix Consulting</a> has its own phone number, those who know me well tend to call my home number rather than risk my having a life outside of work.</p>
<p>My primary VoIP provider is <a href="http://VoiceMeUp.com">VoiceMeUp.com</a> and I have two <a href="http://en.wikipedia.org/wiki/Direct_Inward_Dialing">DIDs</a> (phone numbers) ($4.95 ea) and a prepaid, on-demand plan which bills 30/6 at $0.0185/min. My backup provider is <a href="http://CallWithUs.org">CallWithUs.org</a> who bill $0.0125 in whole minutes; while I hadn&#8217;t originally intended to acquire a DID through CallWithUs.org, I found one for $6/mo which includes 3000 free inbound minutes and couldn&#8217;t pass it up. My base VoIP price is therefore 4.95 * 2 + 6 = $15.90 plus usage, or $7.95 on an even split. Theoretically this leaves me with just over 650 minutes before exceeding my $20 target, but this doesn&#8217;t account for incremental billing, free VoIP to VoIP calls, and other variables which impinge cost.</p>
<p>It&#8217;s now more than a month since I <a href="http://blog.penguins-on-hudson.com/2008/09/19/three-things-to-avoid-in-a-voip-provider/">dumped Broadvoice</a>, ergo September&#8217;s charges and complete usage data are available for a real world comparison against a $40 average, a $35 example, and a $20 target. As it turned out we made no outbound calls on the (secondary) CallWithUs.com trunk and didn&#8217;t exceed the 3000 inbound minutes, so all billable usage was on the VoiceMeUp.com trunk which makes accounting easier. September&#8217;s total was 9.95 + 6 + 23.38 = $39.28 or $19.64 per split which helps validate my &#8220;less than $20 phone bill&#8221; theory. Our total usage was 36h 7m 33s (2167.55 min) or nearly 1,100 &#8220;home&#8221; minutes and more than 2,000 unused inbound minutes&#8211; how much do you talk?</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=138&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/10/04/i-have-seen-the-light/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2008/10/voicemeup-invoice.png?w=300" medium="image">
			<media:title type="html">voicemeup-invoice</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenSSH: Basic Configuration</title>
		<link>http://codefix.wordpress.com/2008/09/26/openssh-basic-configuration/</link>
		<comments>http://codefix.wordpress.com/2008/09/26/openssh-basic-configuration/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 04:20:17 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=86</guid>
		<description><![CDATA[prerequisite concepts: prelude
If you&#8217;re not already using a config file (~/.ssh/config) you should peruse the documentation to see what it offers; an ongoing benefit I enjoy is that it allows me to accomplish more while typing less. Suppose, for example, you need to access two mail servers which are both behind a firewall and sharing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=86&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:right;"><em>prerequisite concepts: <a href="http://blog.penguins-on-hudson.com/2008/09/25/openssh-prelude/"><em>prelude</em></a></em></p>
<p>If you&#8217;re not already using a config file (<span class="code">~/.ssh/config</span>) you should peruse the documentation to see what it offers;<a href="http://www.openssh.com/"><img src="http://codefix.files.wordpress.com/2008/10/puffy-armed.png?w=200&#038;h=170" alt="" title="Puffy, the OpenBSD/OpenSSH mascot." width="200" height="170" class="alignright size-full wp-image-154" /></a> an ongoing benefit I enjoy is that it allows me to accomplish more while typing less. Suppose, for example, you need to access two mail servers which are both behind a firewall and sharing a single public IP address. One server uses NAT (port forwarding) to provide user access via IMAP-SSL, POP3-SSL, and perhaps even webmail, all on default ports; similarly SSH can be accessed on port 22. The other server happens to be a mail relay, which handles all of the spam and virus scanning for inbound and outbound mail; while the SMTP, SMTPS, and submission services all enjoy a NAT configuration using default ports, SSH access is on port 23 because port 22 already forwards to the IMAP server and the sysadmin hasn&#8217;t read this series of articles.<br />
<span id="more-86"></span><br />
As an added bonus, your accounts have usernames which differ from each other (let&#8217;s use &#8220;fred&#8221; and &#8220;barney&#8221;) as well as from your workstation.  To log in to these machines using the command line, you  would type:</p>
<p><code>ssh fred@example.com<br />
ssh -p 23 barney@example.com</code></p>
<p>This isn&#8217;t a great deal of typing but already one can see that differentiating more complex connections may be confusing when distinguished only by the port used. We can clarify things a bit with a config file like this:</p>
<p><code>Host imap<br />
HostName example.com<br />
User fred<br />
Host smtp<br />
HostName example.com<br />
Port 23<br />
User barney</code></p>
<p>Now our SSH commands look nicer:</p>
<p><code>ssh imap<br />
ssh smtp</code></p>
<p>The config file can always be overridden with command line options, so ssh admin@smtp will log in as admin rather than barney, but will still use port 23 and any other options set in <span class="code">~/.ssh/config</span>. Once you start using <span class="code">LocalForward</span> and <span class="code">ProxyCommand</span> command line options quickly become tedious and unwieldy, even if you can remember all options for every host you attend.</p>
<p>One final note, in addition to acting as a convenient alias, the host keywords may also be used to make declarations for groups of servers, or all servers, by using wildcards and pattern-lists. The <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config"><span class="code">ssh_config</span> man page</a> (or your preferred documentation) has a detailed <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config#end"><span class="code">PATTERNS</span> section</a>, but a below is a brief example to whet your appetite:</p>
<pre><span class="comment"># global declarations</span>
  Host *
  ForwardAgent yes
  ForwardX11 yes

<span class="comment"># just for example.com servers</span>
  Host *.example.com
  ServerAliveInterval 60
  StrictHostKeyChecking no</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=86&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/09/26/openssh-basic-configuration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2008/10/puffy-armed.png" medium="image">
			<media:title type="html">Puffy, the OpenBSD/OpenSSH mascot.</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenSSH Prelude: Requisite Knowledge</title>
		<link>http://codefix.wordpress.com/2008/09/25/openssh-prelude/</link>
		<comments>http://codefix.wordpress.com/2008/09/25/openssh-prelude/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 19:26:40 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=75</guid>
		<description><![CDATA[This is a prelude to a series of articles focused on how the sophisticated power of OpenSSH may be harnessed to great advantage with less effort than one might think. Readers already familiar with OpenSSH and passwordless authentication may wish to skip ahead:

OpenSSH: Basic Configuration
OpenSSH: Port Forwarding
OpenSSH: Proxy Connections
OpenSSH: Environmental Override
Planned: Reverse Connections
Planned: Connection Multiplexing
I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=75&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is a prelude to a series of articles focused on how the sophisticated power of <a href="http://en.wikipedia.org/wiki/OpenSSH">OpenSSH</a> may be harnessed to great advantage with less effort than one might think. Readers already familiar with OpenSSH and passwordless authentication may wish to skip ahead:</p>
<p><a href="http://www.openssh.com/"><img class="alignright size-full wp-image-154" title="Puffy, the OpenBSD/OpenSSH mascot." src="http://codefix.files.wordpress.com/2008/10/puffy-armed.png?w=200&#038;h=170" alt="" width="200" height="170" /></a></p>
<p><a href="http://blog.penguins-on-hudson.com/2008/09/26/openssh-basic-configuration/">OpenSSH: Basic Configuration</a><br />
<a href="http://blog.penguins-on-hudson.com/2008/10/16/open-ssh-port-forwarding/">OpenSSH: Port Forwarding</a><br />
<a href="http://blog.penguins-on-hudson.com/2008/10/17/openssh-proxy-connections/">OpenSSH: Proxy Connections</a><br />
<a href="http://codefix.wordpress.com/2008/11/01/openssh-environmental-override/">OpenSSH: Environmental Override</a><br />
<span style="color:#808080;">Planned: Reverse Connections<br />
Planned: Connection Multiplexing</span></p>
<p><span id="more-75"></span>I can add little to the vast collection of <a href="http://www.google.com/search?q=SSH+HowTo">SSH HowTo</a>&#8217;s already posted elsewhere<sup><a href="#ref1" name="refref1" title="">[1]</a></sup>, a quick Google search will usually yield plentiful information specific even to operating systems, distributions, and software versions. The best inclusive reference is <a href="http://www.snailbook.com/">Barrett &amp; Silverman&#8217;s snail book</a>, and I would especially like to thank Richard E. Silverman for helping me grasp the subtleties of <em>ProxyCommand</em>. For similar reasons, I will not delve deeply into the merits of the various SSH authentication mechanisms; however, some general remarks may help set the stage for this series.</p>
<p>It is likely that if you are using SSH keys on a Linux desktop, your key agent is well integrated with your desktop environment by default, and does an excellent job making SSH2 authentication as unobtrusive as possible; even oppressed Windows users can easily install <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY and Pageant</a> to the same end, although I can&#8217;t say whether all the techniques illustrated will work identically with Windows as I don&#8217;t touch the stuff myself.</p>
<ol>
<li><a href="http://fritz.potsdam.edu/projects/sshgate/">SSH, Encrypted Keys, and Cron</a> is a great example. <b><a href="#refref1" name="ref1" title="">^</a></b></li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=75&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/09/25/openssh-prelude/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2008/10/puffy-armed.png" medium="image">
			<media:title type="html">Puffy, the OpenBSD/OpenSSH mascot.</media:title>
		</media:content>
	</item>
		<item>
		<title>Doctor, I&#8217;ve got audit complaints about my kernel log.</title>
		<link>http://codefix.wordpress.com/2008/09/24/doctor-ive-got-audit-complaints-about-my-kernel-log/</link>
		<comments>http://codefix.wordpress.com/2008/09/24/doctor-ive-got-audit-complaints-about-my-kernel-log/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 23:32:48 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Case Study]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=60</guid>
		<description><![CDATA[AppArmor, introduced to Ubuntu with Gutsy, is yet another security tool unleashed upon the infosphere. In part, AppArmor is intended as an alternative to SELinux, which can easily be seen as daunting to configure; unfortunately, many such projects are daunting for those admins forced to walk the plank of unfamiliarity above a sea of expectations. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=60&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://en.wikipedia.org/wiki/AppArmor">AppArmor</a>, introduced to Ubuntu with Gutsy, is yet another security tool unleashed upon the infosphere. In part, AppArmor is intended as an alternative to <a href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux">SELinux</a>, which can easily be seen as <a href="http://www.linux.com/articles/58942">daunting to configure</a>; unfortunately, many such projects are daunting for those admins forced to walk the plank of unfamiliarity above a sea of expectations. Despite a <a href="http://news.cnet.com/8301-13580_3-9796140-39.html?part=rss&amp;subj=news&amp;tag=2547-1_3-0-5">troubled history</a>, the project seems to be here to stay so it is likely only a matter of time before audit messages crop up in one&#8217;s kernel log. For those who find AppArmor unnecessary, unpalatable, or just untimely, herein lies a quick-and-dirty guide for telling AppArmor where to stick its audit complaints.<span id="more-60"></span></p>
<p>Ubuntu&#8217;s <a href="https://help.ubuntu.com/community/AppArmor">community documentation</a> has some basic commands for starting, stopping, disabling, and enabling AppArmor, but if we want to know as little as possible about AppArmor then it&#8217;s not unlikely that we&#8217;re just trying to dispense with a plethora of audit complaints in our kernel log. The first time this happened to me, it was on a box which had some MySQL data in a nonstandard location, resulting in a flood of log entries similar to:</p>
<p><code>Sep 23 11:22:17 bluebeard kernel: [4960023.353512]<br />
audit(1222183337.704:68500): type=1502<br />
operation="inode_permission" requested_mask="r::"<br />
denied_mask="r::" name="/u1/mysql/"<br />
pid=1573 profile="/usr/sbin/mysqld"<br />
namespace="default"</code></p>
<p>To allow mysqld to do its thing in <em>/u1/mysql</em> without sending AppArmor into a conniption fit, just add permissions to its profile, located  by default at <em>/etc/apparmor.d/usr.sbin.mysqld</em> on Ubuntu Hardy systems.</p>
<p><code><span class="comment"># custom permissions</span><br />
/u1/mysql/ r,<br />
/u1/mysql/** rwk,</code></p>
<p>The first line is a comment which makes clear that the lines which follow are not default permissions. The second line grants read access to <em>/u1/mysql/</em>, which AppArmor expects to be a directory due to the trailing slash. The final line uses the <em>/**</em> syntax to specify a group of files and subdirectories, to which are granted access to read, write, and perform locking operations. Note that these rules were simply adapted from the default rules for <em>/var/lib/mysql</em>; such “cut-and-paste” adaptation helps avoid typos and lessens the need for a detailed understanding of the configuration syntax. Note further that <span style="color:#800000;">this is an observation rather than a recommendation</span>.</p>
<p>Once all profiles have been edited to perfection, reload AppArmor and we&#8217;re off to the races.</p>
<p><code>sudo /etc/init.d/apparmor reload</code></p>
<p>When this information proves inadequate, complete documentation and additional resources can be found at  <a href="http://en.opensuse.org/AppArmor">OpenSuse</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=60&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/09/24/doctor-ive-got-audit-complaints-about-my-kernel-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>
	</item>
		<item>
		<title>But I already have a router!</title>
		<link>http://codefix.wordpress.com/2008/08/09/but-i-already-have-a-router/</link>
		<comments>http://codefix.wordpress.com/2008/08/09/but-i-already-have-a-router/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 01:56:15 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Networks]]></category>

		<guid isPermaLink="false">http://codefix.wordpress.com/?p=34</guid>
		<description><![CDATA[Verizon is a great company, doing great things, but that doesn&#8217;t mean they&#8217;re not evil. I&#8217;ve found that this is an effective maxim which allows me to extol the virtues of Verizon without sounding like I&#8217;m drinking the kool-aid. Today I&#8217;m hoping it works inversely as well.
If you subscribe to Verizon FIOS broadband and television, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=34&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://en.wikipedia.org/wiki/Verizon_Communications">Verizon</a> is a great company, doing great things, but that doesn&#8217;t mean they&#8217;re not evil. I&#8217;ve found that this is an effective maxim which allows me to extol the virtues of Verizon without sounding like I&#8217;m drinking the kool-aid. Today I&#8217;m hoping it works inversely as well.<span id="more-34"></span></p>
<p>If you subscribe to Verizon <a href="http://en.wikipedia.org/wiki/FIOS">FIOS</a> broadband and television, then you have an <a href="http://en.wikipedia.org/wiki/FTTP">Optical Network Terminal</a> mounted to an outside wall of your home, from which sprout a coaxial cable and an ethernet cable which connect the ONT to a router inside your home, such as the <a href="http://www.google.com/search?q=ActionTec+MI424-WR">ActionTec MI424-WR</a>.</p>
<p>Verizon technicians will insist that the router they supply must be connected directly to the ONT for your service to function correctly.</p>
<p>They are lying.</p>
<p>The ActionTek router they use isn&#8217;t bad, but it pales in comparison to the wireless gigabit router I&#8217;ve customized with <a href="http://www.dd-wrt.com/">DD-WRT</a> firmware; however, what really burns my toast is when some call center drone (“tech support” is a double misnomer) tells me that their service requires me to reconfigure my network to be less robust, slower, and less secure.</p>
<p>There is absolutely, unequivocally no fathomable reason to use two routers, unless, of course, one has a good reason. In truth, there are legitimate reasons to use multiple routers, firewalls, and access points but technological ignorance is not among them. The arrogant superiorism of the misinformed miscreant who tried to sell me this snake oil only makes me wish he would be boiled in his own vomit and bile.</p>
<p>I feel better now.</p>
<p>Welcoming a new Verizon router into your network can be an easy, painless process. I make the following recommendations under the assumption that you require an already existing router to preside over the Verizon router and either have both routers configured on different subnets or don&#8217;t need to. You should also heed that as I am not privy to the Mysterious Ways of Verizon, this text may contain factual errors, your mileage may vary, and should you break something you should neither find me culpable nor burn my effigy. What would you want with my effigy anyway?</p>
<p>Because I initially set up the Verizon router in accordance with the lies they told me, subnet conflicts were an issue resolved long ago and I had also disabled it&#8217;s wireless transmitter. To make my life easier, I also enabled remote (WAN) administration and assigned a static IP address so I can access the router from my local network, which is a public network from the Verizon router&#8217;s point of view.</p>
<p>If you leave the Verizon router connected only via the coaxial cable, you&#8217;ll soon discover that it needs internet access to retrieve channel and schedule information for your television. To fix this you need to  plug an ethernet cable into a LAN port on your router and the WAN port on the Verizon router; you may also need to forward port 4567 to the Verizon router but as I write this I have yet to try disabling it or complete my research on how Verizon uses this port.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codefix.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codefix.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=34&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/08/09/but-i-already-have-a-router/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>
	</item>
		<item>
		<title>When in doubt, test.</title>
		<link>http://codefix.wordpress.com/2008/01/14/when-in-doubt-test/</link>
		<comments>http://codefix.wordpress.com/2008/01/14/when-in-doubt-test/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 05:30:39 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Case Study]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.penguins-on-hudson.com/2008/01/14/when-in-doubt-test/</guid>
		<description><![CDATA[Shortly after I last upgraded my mail server, one user reported that his mail client was failing to connect with the message:
"Unable to connect to your IMAP server. You may have exceeded the maximum number of connections to this server..."
He was the only one known to be having this issue, so after a cursory check [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=33&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Shortly after I last upgraded my mail server, one user reported that his mail client was failing to connect with the message:</p>
<p><code>"Unable to connect to your IMAP server. You may have exceeded the maximum number of connections to this server..."</code></p>
<p>He was the only one known to be having this issue, so after a cursory check of the server with no obvious problems, I suggested that this might be an error on his end, such as connecting to the secure <a href="http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol">IMAP</a> port without using <a href="http://en.wikipedia.org/wiki/Transport_Layer_Security">SSL</a>/<a href="http://en.wikipedia.org/wiki/Transport_Layer_Security">TLS</a>. Occam’s Razor suggests that a server error is more likely than a client error which just happens to coincide with a server upgrade, so I eventually decided to dig up some infrequently used commands and perform a thorough analysis.<span id="more-33"></span></p>
<p>Testing proved that there was indeed a server problem with certain SSL connections, while others worked every time. Deft Googling revealed that the <i>imapd-ssl</i> config file shipping with <a href="https://wiki.ubuntu.com/GutsyGibbon">Gutsy Gibbon</a> had TLS_PROTOCOL=SSL3, whereas it should be <a href="https://bugs.launchpad.net/ubuntu/+source/courier/+bug/150067">TLS_PROTOCOL=SSL23</a>. The user who first reported the error is tech-savvy, so I sent him the commands I used to diagnose the problem and promised to eventually write this post. Below are the commands which are now my first step in diagnosing mail connection problems.</p>
<p><code># Test secure SMTP<br />
openssl s_client -connect example.com:25 -starttls smtp -showcerts<br />
#<br />
# Test secure IMAP<br />
openssl s_client -ssl2 -connect example.com:993 -showcerts<br />
openssl s_client -ssl3 -connect example.com:993 -showcerts<br />
openssl s_client -tls1 -connect example.com:993 -showcerts</code></p>
<p>To test secure POP, simply substitute 995 for 993 in the above commands, likewise if you run secure SMTP on a port other than 25, you will need to alter the first command.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codefix.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codefix.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=33&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2008/01/14/when-in-doubt-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick and Easy Caller ID on MythTV</title>
		<link>http://codefix.wordpress.com/2007/12/31/quick-and-easy-caller-id-on-mythtv/</link>
		<comments>http://codefix.wordpress.com/2007/12/31/quick-and-easy-caller-id-on-mythtv/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 20:36:24 +0000</pubDate>
		<dc:creator>Garrison</dc:creator>
				<category><![CDATA[Case Study]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[MythTV]]></category>
		<category><![CDATA[Telephony]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.penguins-on-hudson.com/2007/12/31/quick-and-easy-caller-id-on-mythtv/</guid>
		<description><![CDATA[I have resisted the urge to display caller id on my MythTV  as somewhat obvious. I’m always looking for ways to demonstrate the freedom which comes from using open source software, but I prefer the zesty freshness of an original idea rather than anything that’s been done, redone, and done again. My wife, however, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=31&subd=codefix&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have resisted the urge to display caller id on my MythTV <a href="http://codefix.files.wordpress.com/2007/12/mythcid.png" title="Caller ID on MythTV"><img src="http://codefix.files.wordpress.com/2007/12/mythcid.thumbnail.png" alt="Caller ID on MythTV" align="right" /></a> as somewhat obvious. I’m always looking for ways to demonstrate the freedom which comes from using open source software, but I prefer the zesty freshness of an original idea rather than anything that’s been done, redone, and done again. My wife, however, thought that Myth caller id sounded like a great idea and asked me to set it up. What follows is how I did this with the least possible effort.<span id="more-31"></span></p>
<p>I already have a couple <i>Custom-Apps</i> which handle <a href="http://blog.penguins-on-hudson.com/2007/10/16/direct-inward-dialing-with-asterisk-and-broadvoice/">direct inward dialing on my inbound routes</a>, so sending caller id to my MythTV box was as simple as adding one line to each <i>Custom-App</i> in <i>extensions_custom.conf</i>:</p>
<p><code>exten =&gt; s,4,System(/bin/echo "Caller: ${CALLERID(name)} ${CALLERID(number)}" | /usr/bin/nc -w 3 myth.example.com 1234)</code></p>
<p>On the MythTV side I decided to use xosd rather than mythosd because the latter will only work when you are watching live TV or recordings. I created a simple wrapper script called osd.sh:</p>
<p><code>#!/bin/sh<br />
DISPLAY=:0.0<br />
FONT="-xos4-terminus-*-*-*-*-32-*-*-*-*-*-*-*"<br />
osd_cat --font=$FONT --align=centre --shadow=2 --color=SeaGreen –delay=15<br />
</code></p>
<p>At this point I have <a href="http://blog.penguins-on-hudson.com/2007/10/06/red-box/">the PBX</a> sending caller id to MythTV and osd_cat to display the data on screen, but I need a simple way to catch the data on port 1234 and feed it to my osd.sh script. I did this with one command:</p>
<p><code>micro_inetd 1234 ./osd.sh &amp;</code></p>
<p>Micro_inetd is a nice replacement for inetd, xinetd, etc. if, as here, only one service needs to be managed. I set this to always start with xfce4-autostart-editor which naturally only works with the Xfce 4 desktop environment. Gnome, KDE, and other desktops have their own session managers.</p>
<p>Of course, now that we have caller id on the TV, I&#8217;ll need to create a caller id lookup to compensate for the wretched state of telco support; fortunately I can put that off until next year <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><b>Update:</b> change osd.sh to format phone numbers</p>
<p><code>#!/bin/sh<br />
DISPLAY=:0.0<br />
FONT="-xos4-terminus-*-*-*-*-32-*-*-*-*-*-*-*"<br />
cid=`cat | perl -pe 's/(1?\d{3})(\d{3})(\d{4})/$1.$2.$3/'`<br />
echo "$cid" | osd_cat --font=$FONT --align=centre --shadow=2 \<br />
--color=SeaGreen --delay=15<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codefix.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codefix.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codefix.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codefix.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codefix.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codefix.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codefix.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codefix.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codefix.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codefix.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codefix.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codefix.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codefix.wordpress.com&blog=1031461&post=31&subd=codefix&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codefix.wordpress.com/2007/12/31/quick-and-easy-caller-id-on-mythtv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/932fa462763c5b3be2e55e2bb2053999?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">codefix</media:title>
		</media:content>

		<media:content url="http://codefix.files.wordpress.com/2007/12/mythcid.thumbnail.png" medium="image">
			<media:title type="html">Caller ID on MythTV</media:title>
		</media:content>
	</item>
	</channel>
</rss>