<?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>CertPal &#187; ssh</title>
	<atom:link href="http://www.certpal.com/blogs/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.certpal.com/blogs</link>
	<description>Technology and certifications</description>
	<lastBuildDate>Mon, 18 Jul 2011 06:48:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to open multiple SSH tunnels</title>
		<link>http://www.certpal.com/blogs/2010/03/howto-ssh-tunnel-multiple/</link>
		<comments>http://www.certpal.com/blogs/2010/03/howto-ssh-tunnel-multiple/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 08:07:52 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=602</guid>
		<description><![CDATA[OpenSSH can be used to open multiple tunnels to remote services via SSH. Local ports can be opened up and the information communicated with these ports can be relayed to a remote machine. This tutorial explains how to open many ssh tunnels]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fhowto-ssh-tunnel-multiple%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fhowto-ssh-tunnel-multiple%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/tunnel.png"><img class="aligncenter size-full wp-image-603" style="border: 1px dashed black;" title="tunnel" src="http://www.certpal.com/blogs/wp-content/uploads/tunnel.png" alt="" width="282" height="170" /></a></p>
<p style="text-align: left;">
<p style="text-align: left;">I use remote linux services often and exposing them as local services can be performed securely using SSH. For example you can access a tomcat server or email server hosted at IP 1.2.3.4 by opening a secure SSH tunnel between your local machine and the target address &#8211; 1.2.3.4.</p>
<p>The <a href="http://www.openssh.com/" target="_blank">OpenSSH tool</a> can be used to perform SSH related activities on your machine. Simply install it with yum, apt-get or Yast, if it is not already available. Once you have it use the following command to open multiple SSH tunnels to your services</p>
<p><strong>Open tunnel and execute commands:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> 1.2.3.4 <span style="color: #660033;">-lmyUser</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">3098</span>:1.2.3.4:<span style="color: #000000;">21</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">3099</span>:1.2.3.4:<span style="color: #000000;">80</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">3100</span>:1.2.3.4:<span style="color: #000000;">443</span></pre></div></div>

<p>The command is explained below</p>
<p><strong>1.2.3.4</strong> &#8211; Your target IP</p>
<p><strong>l</strong> &#8211; The user to login as</p>
<p><strong>L</strong> &#8211; A local tunnel to a remote port</p>
<p><strong>3098</strong> &#8211; The local port to use when establishing this tunnel</p>
<p><strong>21</strong> &#8211; The remote port at 1.2.3.4 to which the tunnel will be established</p>
<p>Multiple tunnels can be opened by specifying multiple -L flags. For example http://localhost:3099 will now redirect to http://1.2.3.4:80/ That is a fancy way of saying all HTTP requests ( 80 is the default port ) for 1.2.3.4 can now be reached locally at port 3099.</p>
<p>Note that the above command will also log you into the remote system. If you want to open the tunnels alone, use the -N switch and the -f switch as shown below</p>
<p><strong>Open tunnels only:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-f</span> myUser<span style="color: #000000; font-weight: bold;">@</span>1.2.3.4 <span style="color: #660033;">-L</span> <span style="color: #000000;">3099</span>:1.2.3.4:<span style="color: #000000;">25</span> <span style="color: #660033;">-N</span></pre></div></div>

<p>The -f switch asks SSH to work in the background and -N asks SSH not to execute any commands.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fhowto-ssh-tunnel-multiple%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fhowto-ssh-tunnel-multiple%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/03/howto-ssh-tunnel-multiple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

