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

<channel>
	<title>BioTeam Inc. &#187; command line</title>
	<atom:link href="http://blog.bioteam.net/tag/command-line/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bioteam.net</link>
	<description>Latest news: publications, presentations, projects and training classes</description>
	<lastBuildDate>Thu, 29 Jul 2010 14:15:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Cluster user training</title>
		<link>http://blog.bioteam.net/2009/12/21/cluster-user-training/</link>
		<comments>http://blog.bioteam.net/2009/12/21/cluster-user-training/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 19:57:19 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[gridengine]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=365</guid>
		<description><![CDATA[On the same trip to India, I found myself in the position of delivering a training session to a room with incredibly varied backgrounds and skill levels. Some folks had never edited a file on the Unix command line before. Others just wanted to know where MPICH was installed. This set of slides goes from [...]]]></description>
			<content:encoded><![CDATA[<p>On the same trip to India, I found myself in the position of delivering a training session to a room with incredibly varied backgrounds and skill levels.  Some folks had never edited a file on the Unix command line before.  Others just wanted to know where MPICH was installed.  This set of slides goes from an introduction to the bash shell through building MPI programs and SGE integration.</p>
<p>Please do not re-distribute without attribution.</p>
<p><a href="http://blog.bioteam.net/wp-content/uploads/2009/12/2009-Cluster-User.pdf"><img class="alignnone size-full wp-image-367" title="cluster_user_icon" src="http://blog.bioteam.net/wp-content/uploads/2009/12/cluster_user_icon.png" alt="" width="172" height="135" /></a></p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=365&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/12/21/cluster-user-training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inquiry Cluster Admin Slides</title>
		<link>http://blog.bioteam.net/2009/12/21/inquiry-cluster-admin-slides/</link>
		<comments>http://blog.bioteam.net/2009/12/21/inquiry-cluster-admin-slides/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 19:38:32 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[SGE]]></category>
		<category><![CDATA[slides]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=358</guid>
		<description><![CDATA[I recently took a trip to Kolkata, India to train users and administrators of an Apple / Inquiry compute cluster there. The slides I developed for that trip may be of general interest, and so I&#8217;m sharing them here. The intent of these slides is to provide an overview of the administrative tools and systems [...]]]></description>
			<content:encoded><![CDATA[<p>I recently took a trip to Kolkata, India to train users and administrators of an Apple / Inquiry compute cluster there.  The slides I developed for that trip may be of general interest, and so I&#8217;m sharing them here.  The intent of these slides is to provide an overview of the administrative tools and systems used in an Apple Inquiry cluster.</p>
<p>Please do not redistribute without attribution.  </p>
<p><a href='http://blog.bioteam.net/wp-content/uploads/2009/12/Cluster_Admin.pdf'><img src="http://blog.bioteam.net/wp-content/uploads/2009/12/cluster_admin_icon.png" alt="" title="cluster_admin_icon" width="169" height="134" class="alignnone size-full wp-image-361" /></a></p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=358&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/12/21/inquiry-cluster-admin-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up LOM on an Apple XServe from the command line</title>
		<link>http://blog.bioteam.net/2009/12/03/setting-up-lom-on-an-apple-xserve-from-the-command-line/</link>
		<comments>http://blog.bioteam.net/2009/12/03/setting-up-lom-on-an-apple-xserve-from-the-command-line/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 15:48:05 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=354</guid>
		<description><![CDATA[Apple provides a GUI for setting up the IP address and authentication information on the LOM.  The problem, for me, with using a GUI for something like this is that it's nearly impossible to script and automate.  When I'm setting up a cluster of even a dozen nodes, going through a remote desktop to a GUI becomes intolerable in a hurry.  This post shares my recipe for getting the LOM ports on the network and accessible, using only the command line.]]></description>
			<content:encoded><![CDATA[<p>Apple&#8217;s XServe comes with a Lights Out Management (LOM) capability.  For anyone dealing with co-located servers or clusters, this is an essential feature.  Remote monitoring, power, and so on are lifesavers when something goes wrong.</p>
<p>Apple provides a GUI for setting up the IP address and authentication information on the LOM.  The problem, for me, with using a GUI for something like this is that it&#8217;s nearly impossible to script and automate.  When I&#8217;m setting up a cluster of even a dozen nodes, going through a remote desktop to a GUI becomes intolerable in a hurry.  </p>
<p>The command line tool for changing settings on the LOM is a standard one called &#8216;ipmitool&#8217;.  While the internal documentation is good, the usage can be a little obscure.  Here, therefore, are the commands that I use to set up and enable channel 1 (ethernet port 1, or eth0):</p>
<p>I feel compelled to note that you will need to use different IP addresses for the various hosts you&#8217;re setting up.  Also, you *really* don&#8217;t want to set the LOM Ip address to conflict with the IP address of the operating system.  Really, you&#8217;re setting up a small, separate, out of band machine to manage the big expensive server.  Think of it as a different machine, and you&#8217;ll be all set.</p>
<p>For most of the clusters I build, I address the compute nodes as 192.168.2.1 = node001, and so on.  For clusters of less than 100 nodes, I set the LOM address to the node address plus 100.  Thus, these settings would be appropriate for node015.</p>
<p><code>ipmitool lan set 1 ipaddr 192.168.2.115<br />
ipmitool lan set 1 netmask 255.255.255.0<br />
ipmitool lan set 1 defgw ipaddr 192.168.2.254<br />
ipmitool lan set 1 access on<br />
ipmitool lan set 1 arp respond on</code></p>
<p>At this point, the IP address of the LOM ought to respond to pings.  All that&#8217;s left is to set up and enable a user account.  Note that we&#8217;re now talking about user number two, rather than port number 1:</p>
<p><code>ipmitool user set name 2 admin<br />
ipmitool user set password 2<br />
  ** You get to type the password twice **<br />
ipmitool user enable 2</code></p>
<p>FInally, I associate user number 2 with port number 1:</p>
<p><code>ipmitool user priv 2 4 1</code></p>
<p>I have yet to find a way around typing all those IP addresses into the Server Monitor tool.</p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=354&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/12/03/setting-up-lom-on-an-apple-xserve-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH tunnels part 3:  Reverse tunnels</title>
		<link>http://blog.bioteam.net/2009/11/04/ssh-tunnels-part-3-reverse-tunnels/</link>
		<comments>http://blog.bioteam.net/2009/11/04/ssh-tunnels-part-3-reverse-tunnels/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 15:05:15 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[reverse ssh]]></category>
		<category><![CDATA[reverse ssh tunnel]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh tunnel]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=328</guid>
		<description><![CDATA[The problem addressed here is the same as the previous two, except that the remote administrator won't open up *any* ports in their firewall.  Machines on the customer's network can connect <b>out</b> onto the internet, but there is no direct way to connect to them from out here.  This post describes how to set up a pair of tunnels that meet in the middle, allowing me access to machines that don't even have a public IP address.]]></description>
			<content:encoded><![CDATA[<p>In the previous two posts, I laid out the basics of forward ssh tunnels.  Now it&#8217;s time to delve into the dark magic of the reverse tunnel.  For reference, here are the first two articles:</p>
<p>* <a href="http://blog.bioteam.net/2009/10/30/ssh-tunnels-for-beginners/">Intro to ssh tunnels</a><br />
* <a href="http://blog.bioteam.net/2009/11/01/ssh-tunnels-part-2/">Chaining ssh tunnels together</a></p>
<p>The problem addressed in this post is the same as the previous two, except that the remote administrator won&#8217;t open up *any* ports in their firewall.  Machines on the customer&#8217;s network can connect <strong>out</strong> onto the internet, but there is no direct way to connect <strong>in</strong> from out here.  This is remarkably common, either because the admin only has a limited number of public IP addresses, or because most organizations are very private with their machines.   This post describes how to set up a pair of tunnels that meet in the middle on my co-located server, allowing me access to machines that don&#8217;t even have a public IP address.</p>
<p>Ssh tunnels are <strong>directional</strong>.  When I open a tunnel with &#8220;-L&#8221;, I am opening a path from the originating machine <strong>forward</strong> to the target.  The other tunnel argument, &#8220;-R&#8221;, opens a <strong>reverse</strong> tunnel from a port on the destination machine back to the originator.  In the <a href="http://blog.bioteam.net/2009/11/01/ssh-tunnels-part-2/">second post</a> I set up a connection letting me see into remote.customer.com from demo.bioteam.net.  However, someone sitting at remote.customer.com wouldn&#8217;t be able to see back down that tunnel.</p>
<p>It&#8217;s worth noting that at this point we run a risk of violating security policies at the customer site.  By enlisting a co-conspirator inside the firewall, we&#8217;re getting access to resources that are very clearly supposed to be inaccessible.  Bioteam&#8217;s practice is to be totally above board about what we are doing and why we&#8217;re doing it.  Many security / networking folks agree that the goal of a network setup like this is to prevent <strong>unauthorized</strong> access.  In that circumstance, we can frequently agree that my access is authorized, and that it&#8217;s simpler for short term or one time connections to use ssh tunnels to get the job done.  However, if the policy is actually to prevent <strong>any</strong> remote access, there&#8217;s no getting around it.  In those cases, I get in a car or on a plane.  Many of my long term clients have started off giving me reverse ssh tunnels while we waited for the organizational paperwork on a &#8220;real&#8221; solution like VPN access.</p>
<p>Short version:  There are times when it&#8217;s better to ask forgiveness than permission.  Dealing with network security is not one of them.  Building trust with the people responsible for a computing network requires both honesty and demonstrated competence over a period of time.  If you sneak around behind people&#8217;s backs, you will eventually get burned.</p>
<p>The target machine is called:  <code>customer.private</code><br />
I have an account on that machine: <code>bioteam</code><br />
Bioteam&#8217;s co-located server is still:  <code>demo.bioteam.net</code><br />
My account on bioteam&#8217;s server: <code>cdwan</code><br />
The customer also gets an account on bioteam&#8217;s server:  <code>customer</code></p>
<p>The customer needs to be logged into <code>customer.private</code> and connect from there to <code>demo.bioteam.net</code> like this:</p>
<p><code>ssh demo.bioteam.net -l customer <strong>-R 9001:customer.private:80</strong></code></p>
<p>That specification has three parts:</p>
<p>* 9001:  The port <strong>on demo.bioteam.net</strong> on which the tunnel listens<br />
* customer.private:  The machine on which the tunnel ends.  This is the part where terms like &#8220;localhost&#8221; get really confusing.  In this case &#8220;localhost&#8221; would work just as well, but I&#8217;m making it explicit.<br />
* 80:  The port where the tunnel ends.</p>
<p>From my laptop, I open up a forward tunnel exactly as before:</p>
<p><code>ssh demo.bioteam.net -l cdwan -L 9000:localhost:9001</code></p>
<p>That&#8217;s it.  We&#8217;ve got a tunnel from my side to port 9001 on <code>demo.bioteam.net</code>, and another tunnel from 9001 to port 80 on <code>customer.private</code>.  I connect to <code>http://localhost:9000</code> on my laptop, and I should see the webserver on customer.private.  We&#8217;ve created the same chained pair of tunnels from the <a href="http://blog.bioteam.net/2009/11/01/ssh-tunnels-part-2/">previous post</a>, but with one originating on each side rather than me pushing both of them forward.</p>
<p>The attentive reader may ask &#8220;if there&#8217;s a tunnel listening at demo.bioteam.net:9001, can&#8217;t you just connect your web server directly to <code>http://demo.bioteam.net:9001</code>?   This is a good question.  The answer is &#8220;yes, but you need to explicitly ask for this functionality.&#8221;  By default, ssh tunnels only listen to requests originating from within the machine itself.  The tunnel listens on what is called the &#8220;loopback&#8221; interface and is not visible from outside the machine.  While it&#8217;s possible to get around this, I&#8217;ve found it to be a universally bad idea in my work with Bioteam.  It represents enough of a potential security hole that I just don&#8217;t do it.</p>
<p>Notice also that the customer didn&#8217;t have to give me an ssh account on their machine.  Instead, we both connected to some machine in the middle (demo.bioteam.net) and I was able to see their web server.   As before, as soon as either ssh connection closes, the access is gone.  This has a pleasing symmetry insofar as I&#8217;m asking for access by giving the customer an account on my machine.</p>
<p>Now for the meat of it:  Assume that the customer wants to let me log in via ssh.  This means that the reverse tunnel needs to terminate at the ssh port (22) rather than the http port (80).  Otherwise it&#8217;s exactly the same:</p>
<p><code>ssh demo.bioteam.net -l customer -R 9002:customer.private:22</code></p>
<p>With that in place, I can log in to <code>demo.bioteam.net</code> and then run this:</p>
<p><code>ssh localhost -l bioteam -p 9002</code></p>
<p>If everything has gone correctly, I will get a password prompt, type my password for cutomer.private, and see a shell prompt for a machine without a public internet IP.</p>
<p>Of course, I can create my own tunnels using that connection.  For example, with the reverse tunnel from above in place, I can set up my very own tunnel from port 9010 on my laptop, through port 9011 on demo.bioteam.net, to the webserver on remote.customer.com.  This is the part where the &#8220;localhosts&#8221; get almost impenetrably confusing:</p>
<p><code>ssh demo.bioteam.net -l cdwan -L 9010:localhost:9011<br />
ssh localhost -l bioteam -p 9002 -L 9011:localhost:80</code></p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=328&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/11/04/ssh-tunnels-part-3-reverse-tunnels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Tunnels &#8211; part 2</title>
		<link>http://blog.bioteam.net/2009/11/01/ssh-tunnels-part-2/</link>
		<comments>http://blog.bioteam.net/2009/11/01/ssh-tunnels-part-2/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 21:41:25 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh tunnel]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=323</guid>
		<description><![CDATA[In a previous post I described how and why one might set up a very simple ssh tunnel in order to access a web server or a remote desktop server on a machine with a restrictive firewall.  This post goes one step deeper, showing how to chain tunnels together.]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://blog.bioteam.net/2009/10/30/ssh-tunnels-for-beginners/">previous post</a> I described how and why one might set up a very simple ssh tunnel in order to access a web server or a remote desktop server on a machine with a restrictive firewall.  This post goes one step deeper, showing how to chain tunnels together.</p>
<p>With this added complexity, we have hit the point where there are many, many ways to skin this particular cat.  My aim in these posts is to show how <strong>I</strong> do things, demonstrating the underlying tools along the way.  Hopefully, this will let you build up your own set of techniques in a way that makes sense to you.</p>
<p>A very common practice among the network security folks I meet is to ask &#8220;where will you be logging in from?&#8221;  They then make an exception in their firewall rules for traffic from my particular machine.  This makes a lot of sense, but it limits my flexiblity.   If I give them the address of my home internet connection, then I won&#8217;t be able to connect while I&#8217;m on the road, and so on.  In addition, if I need to let my colleagues see what I&#8217;m dealing with in order to get their help debugging something, we need a way to share that hole in the firewall.</p>
<p>My solution is to give an IP address of a server in Bioteam&#8217;s co-location facility, and then use ssh tunnels to bounce my connections through that server and into the customer&#8217;s network.  This has the added social benefit of giving the customer a &#8220;bioteam.net&#8221; IP address rather than my home.  I think that this looks a bit more professional.</p>
<p>My server is called &#8220;demo.bioteam.net&#8221;<br />
I log into my server with the username &#8220;cdwan&#8221;</p>
<p>The customer&#8217;s server is &#8220;remote.customer.com&#8221;<br />
I log into the customer&#8217;s server with the username &#8220;bioteam&#8221;</p>
<p>As before, the first thing to check is that straightforward, vanilla ssh connections work:</p>
<p><code>ssh demo.bioteam.net -l cdwan</code></p>
<p>I will be prompted for a password.   This first time, I enter the password for &#8220;cdwan&#8221; on the bioteam machine.  Next, within that ssh session, I connect to the customer&#8217;s machine:</p>
<p><code>ssh remote.customer.com -l bioteam</code></p>
<p>Again, the password prompt &#8211; but this time I have to enter the password for &#8220;bioteam&#8221; on the customer&#8217;s machine.</p>
<p>It feels a little pedantic to specify which password goes where, but I find that the second most common source of confusion about ssh tunnels is figuring out which machine is demanding a password.  As you start to build up more and more complex systems, it&#8217;s key to remember where you are and where you are trying to go.</p>
<p>Assume that we want to take a look at the web server on the remote machine.  If the security folks made a complete (all ports) exception for my host (demo.bioteam.net), then this is pretty simple.  From my laptop, I do this:</p>
<p><code>ssh demo.bioteam.net -l cdwan <strong>-L 8999:remote.customer.com:80</strong></code></p>
<p>This is exactly the same as the first example in the <a href="http://blog.bioteam.net/2009/10/30/ssh-tunnels-for-beginners/">first post</a> in this series, except that instead of connecting to &#8220;localhost,&#8221; I&#8217;m telling ssh to point at some external machine.</p>
<p>I will make a practice of changing the port number in these examples (8999 vs. 9000 in this case) to demonstrate that it doesn&#8217;t matter what number you use <strong>as long as it is not in use for anything else</strong>.  If you try to open a tunnel on a port that is already in use by another process (someone else&#8217;s ssh tunnel to a different machine, for example) the command will fail.</p>
<p>There is a pretty safe range of ports from about 8900 to about 9100 that I tend to use for these purposes.  I make a practice of picking numbers pretty much at random.  You should do the same, rather than just hitting &#8220;up arrow, return&#8221; on some command cut and pasted from a blog post.</p>
<p>In actual practice, Bioteam sets up virtual machines &#8211; one per customer &#8211; to prevent us from stepping on each other&#8217;s connections and ssh keys.  This has other benefits as well, the best being that we can give customers an account on our systems to share files &#8211; which is often simpler to do than convincing their networking team to let us into their machines.</p>
<p>Anyway, with the above tunnel in place, I can look at the URL below and see the remote machine:</p>
<p><code>http://localhost:8999</code></p>
<p>It&#8217;s worth noting that I could do almost the same thing by opening a remote desktop (or VNC) connection to demo.bioteam.net and running a web browser in that remote session.  I find this to be inferior because remote desktops invariably have less pixels and worse mouse control than my local browser.</p>
<p>I would use exactly the same sort of command if the customer wanted me to use their &#8220;DMZ&#8221; gateway machine to access their network, rather than my own.  This happens in lots of cases.  The key here is that once I have ssh access to a machine &#8211; I can point whatever application I want at anything that machine can see.</p>
<p>The setup above works as long as there is a clear path from demo.bioteam.net to remote.customer.com.  As an additional complexity, assume that we now encounter the firewall problem from my first post.  The security folks only opened port 22 (ssh) and only from demo.bioteam.net.</p>
<p>To overcome this, we need to chain ssh tunnels together.  Here&#8217;s the example:</p>
<p><code>ssh demo.bioteam.net -l cdwan <strong>-L 8999:localhost:9000</strong></code></p>
<p>From within that session, connect to the remote machine like this:</p>
<p><code>ssh remote.customer.com -l bioteam <strong>-L 9000:localhost:80</strong></code></p>
<p>And then look at the same URL:</p>
<p><code>http://localhost:8999</code></p>
<p>Here&#8217;s what happens:  I have one tunnel leading from my laptop&#8217;s port 8999 to port 9000 on demo.bioteam.net.  I have a <strong>second</strong> tunnel from port 9000 into remote.customer.com.  Under the hood, ssh near-magically forwards packets along and does the right thing to tie them together.</p>
<p>There is absolutely no need for those tunnels to be opened in the same ssh session or from the same terminal.  In fact, in the next post I will show how to open one tunnel from each side to meet in the middle.</p>
<p>It is possible to chain tunnels together arbitrarily.  The longest series that I&#8217;ve ever built was three deep, but I&#8217;m not aware of any fundamental limitation on that &#8211; other than my own ability to keep track of accounts and passwords.</p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=323&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/11/01/ssh-tunnels-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH Tunnels For Beginners</title>
		<link>http://blog.bioteam.net/2009/10/30/ssh-tunnels-for-beginners/</link>
		<comments>http://blog.bioteam.net/2009/10/30/ssh-tunnels-for-beginners/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 14:48:32 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh tunnel]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=318</guid>
		<description><![CDATA[A basic introduction to ssh tunnels:  As a first puzzle, assume that a friendly administrator gave me an ssh account on her web server.  However, her organization's security scheme only allows me to get to port 22.  I can ssh in, but I can't really debug some problem with the web browser because port 80 is still blocked.  Assume as well that we've already called up the network administrator, who offered to think about it - laughed maniacally - and hung up on us. ]]></description>
			<content:encoded><![CDATA[<p>SSH tunnels are some of the most powerful utilities in the entire command line arsenal.  They allow me to connect to arbitrary ports on remote machines.  I use them daily to navigate the somewhat arbitrary networking requirements that I encounter from both software tools and network administrators.  I have found that it is invariably easier to figure out how to construct a tunnel than it is to convince network security folks to open more ports in their firewalls.  Even though I can be flippant about this, all of these techniques remain true to the spirit, if occasionally subverting the letter, of the network access requirements imposed by my customers.</p>
<p>This post provides a very basic intro to forward tunnels.  I hope to shed some light on reverse tunnels in a future post.</p>
<p>Firewalls and other network devices frequently limit the network ports that I am allowed to access.  A very reasonable policy might only allow access over ssh (port 22) from machines outside of a local network.  That&#8217;s well and good, but in my work I often need to see web servers (port 80) and/or Apple&#8217;s Remote Desktop or VNC (port 5900).</p>
<p>As a first puzzle, assume that a friendly administrator gave me an ssh account on her web server.  However, because I&#8217;m not working onsite, her organization&#8217;s security scheme only allows me to get to port 22.  I can ssh in, but I can&#8217;t really debug some problem with the web browser because port 80 is still blocked.  Assume as well that we&#8217;ve already called up the network administrator, who said &#8220;no,&#8221; there are no exceptions to this security policy.</p>
<p>The remote machine is called:  &#8220;remote.customer.com&#8221;<br />
I will log into that remote machine with an account called &#8220;cdwan&#8221;</p>
<p>I run this perfectly ordinary ssh command to log in, and it works:</p>
<p><code>ssh remote.customer.com -l cdwan</code></p>
<p>Keep in mind that if that first command doesn&#8217;t work &#8211; there&#8217;s nothing I can do to make the rest work.  With that in hand, I am going to add the forward tunnel specification:</p>
<p><code>ssh remote.customer.com -l cdwan <strong>-L 9000:localhost:80</strong></code></p>
<p>The tunnel specification is in three parts:</p>
<p>* First is the port on <strong>my</strong> local machine into which I peer<br />
* The middle is the target hostname I want to connect to <strong>as it is seen on the remote machine</strong>.  In this simple example, I&#8217;m going to &#8220;localhost&#8221;, which really means &#8220;remote.customer.com&#8221;.  I think that this is the most frequent source of confusion with tunnels, figuring out the context in which hostnames are evaluated.<br />
* Last  is the port to connect <strong>to</strong> on that target machine.  That&#8217;s where the tunnel ends.</p>
<p>So, I&#8217;m setting up a connection from my local machine&#8217;s port 9000 to port 80 on remote.customer.com.</p>
<p>Once that tunnel is in place, I should be able to open a web browser and look at the URL below to see the web server on the remove machine:</p>
<p><code>http://localhost:9000</code></p>
<p>From the point of view of the web browser, I&#8217;m looking at port 9000 on my local machine.  My ssh connection is catching those requests on port 9000, forwarding them along to the remote machine, and passing them to port 80.  Responses come back by the same route.</p>
<p>The connection will only stay open as long as the ssh connection is active.  As soon as I log out, my tunnel goes away.  While I&#8217;m connected, all of my traffic goes over port 22, and is encrypted in exactly the same way as the rest of my ssh traffic.  It&#8217;s actually a remarkably stable and secure solution to this problem.</p>
<p>I&#8217;ll close this post with the fact that ssh accepts multiple instances of the &#8220;-L&#8221; flag.  So, if I want to connect to both a web server (port 80) and a remote desktop server (port 5900), I can do this:</p>
<p><code>ssh remote.customer.com -l cdwan -L 9000:localhost:80 -L 9001:localhost:5900</code></p>
<p>With that in place, I can point my web browser at localhost:9000, and my remote desktop client at localhost:9001.</p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=318&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/10/30/ssh-tunnels-for-beginners/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Binding Apple&#8217;s Open Directory from the Command Line</title>
		<link>http://blog.bioteam.net/2009/10/29/binding-apples-open-directory-from-the-command-line/</link>
		<comments>http://blog.bioteam.net/2009/10/29/binding-apples-open-directory-from-the-command-line/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 16:32:35 +0000</pubDate>
		<dc:creator>cdwan</dc:creator>
				<category><![CDATA[Employee Posts]]></category>
		<category><![CDATA[tech notes]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://blog.bioteam.net/?p=314</guid>
		<description><![CDATA[Here is a trick I use a couple of times a month to get finicky compute nodes in a Apple compute clusters to correctly bind to their LDAP / Open Directory master. This started working as of OS X 10.4, and to my knowledge it still works as of OS X 10.6.1. Bioteam uses a [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a trick I use a couple of times a month to get finicky compute nodes in a Apple compute clusters to correctly bind to their LDAP / Open Directory master.  This started working as of OS X 10.4, and to my knowledge it still works as of OS X 10.6.1.</p>
<p>Bioteam uses a pretty standard architecture, where the portal has the IP address and domain settings below. Modifying those for your particular setup is left as an exercise for the reader.</p>
<p><code>ldapsearch -h 192.168.2.254 -b "dc=cluster,dc=private" -x</p>
<p>slapconfig -setldapstatic 192.168.2.254</code></p>
<p>Apple&#8217;s &#8220;Directory Utility&#8221; GUI app is great, but for cluster maintenance you really can&#8217;t beat the command line.</p>
<img src="http://blog.bioteam.net/?ak_action=api_record_view&id=314&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.bioteam.net/2009/10/29/binding-apples-open-directory-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
