<?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>The Daily Build &#187; ssh</title>
	<atom:link href="http://blog.bstpierre.org/tag/ssh/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bstpierre.org</link>
	<description>Software Development, version 3.0</description>
	<lastBuildDate>Wed, 26 May 2010 16:08:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use SSH to Forward Multiple Protocols to Multiple Machines</title>
		<link>http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines</link>
		<comments>http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines#comments</comments>
		<pubDate>Fri, 04 Dec 2009 16:03:33 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[ssh]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=239</guid>
		<description><![CDATA[Let's say you have a half-dozen machines at work you want to log into. Instead of setting up a remote forwarding connection from each of those machines, you can have the connection from your main machine perform multiple forwardings instead of just one. This even works if some of the machines don't support ssh.


Related posts:<ol><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/local-ssh-forwarding' rel='bookmark' title='Permanent Link: Use Local SSH Forwarding to Reduce the Number of Manual Hops'>Use Local SSH Forwarding to Reduce the Number of Manual Hops</a> <small>Local port forwarding is the same...</small></li><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><em>(This is part five in a <a href="../category/tools/ssh">series of posts on ssh</a>.)</em></p>
<p>Let&#8217;s say you have a half-dozen machines at work you want to log into. Instead of setting up a <a href="http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels">remote forwarding connection</a> from each of those machines, you can have the connection from your main machine perform multiple forwardings instead of just one. This even works if some of the machines don&#8217;t support ssh.</p>
<p>It shouldn&#8217;t surprise you at this point that you can do this with your config file. On your work machine, you might have something like:</p>
<pre>Host tunnel
  HostName cloud.example.com
  User mycloudusername
  IdentityFile ~/.ssh/id_dsa
  Port 22
  RSAAuthentication yes
  PubkeyAuthentication yes
  ExitOnForwardFailure yes
  # tunnel ssh to myworkmachine
  RemoteForward 4022 localhost:22
  # tunnel remote desktop to mywindowsbox via myworkmachine
  RemoteForward 5389 192.168.4.10:3389
  # tunnel http to mywindowsbox via myworkmachine
  RemoteForward 5080 192.168.4.10:80
  # tunnel remote desktop to otherwindowsbox via myworkmachine
  RemoteForward 6389 192.168.4.11:3389
  # tunnel ssh to workserver via myworkmachine
  RemoteForward 7022 192.168.4.2:22</pre>
<p>You can add a bunch of forwardings as shown above. Each entry will open the given port on cloud and forward it to the specified port on the specified machine. Now when you run &#8220;ssh tunnel&#8221; on your work machine, it will connect to cloud and set up the five port forwardings specified in your config file.</p>
<p>Then when logged in to cloud.example.com, you can do, for example, &#8220;ssh -p 7022 myserverlogin@localhost&#8221; to log into the machine called workserver.</p>
<p>If you mirror the remote forwardings in your home config file as local forwardings, then when you &#8220;ssh work&#8221; from home you can remote desktop to a windows machine from your home pc by doing &#8220;rdesktop -u myworkwinuser localhost:5389&#8243; and it will use the tunnel. (The connection will go from your home pc to cloud, to myworkmachine, to mywindowsbox.) The windows machine does not need to know anything about ssh.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/local-ssh-forwarding' rel='bookmark' title='Permanent Link: Use Local SSH Forwarding to Reduce the Number of Manual Hops'>Use Local SSH Forwarding to Reduce the Number of Manual Hops</a> <small>Local port forwarding is the same...</small></li><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open an SSH Tunnel in Four Seconds or Less</title>
		<link>http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less</link>
		<comments>http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less#comments</comments>
		<pubDate>Thu, 03 Dec 2009 15:28:47 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[ssh]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=233</guid>
		<description><![CDATA[As I mentioned in a previous post on ssh configuration, your config file can specify a variety settings for each server. In fact, the Hosts you use don't even have to exist! Consider the following snippet in your ~/.ssh/config.


Related posts:<ol><li><a href='http://blog.bstpierre.org/local-ssh-forwarding' rel='bookmark' title='Permanent Link: Use Local SSH Forwarding to Reduce the Number of Manual Hops'>Use Local SSH Forwarding to Reduce the Number of Manual Hops</a> <small>Local port forwarding is the same...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><em>(This is part four in a <a href="../category/tools/ssh">series of posts on ssh</a>.)</em></p>
<p>As I mentioned in a previous post on <a href="http://blog.bstpierre.org/configure-ssh-username">ssh configuration</a>, your config file can specify a variety settings for each server.</p>
<p>In fact, the Hosts you use don&#8217;t even have to exist! (The HostName is the important part.) Consider the following snippet in your ~/.ssh/config.</p>
<pre>#
Host work
  HostName localhost
  User myworklogin
  IdentityFile ~/.ssh/id_dsa
  Port 4022
  RSAAuthentication yes
  PubkeyAuthentication yes
  LocalForward 4022 localhost:4022</pre>
<p>I&#8217;m going to assume remote forwarding is set up and the connection is open from work to cloud as described in <a href="http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels">this post on remote forwarding</a>; and you&#8217;ve got local forwarding set up from home to cloud as described in this post on <a href="http://blog.bstpierre.org/local-ssh-forwarding">local port forwarding</a>.</p>
<p>Now you can do &#8220;ssh work&#8221; from your home pc, and it will automatically log you into your work pc with the right credentials using the tunnel on cloud.example.com. And the scp example above simplifies to &#8220;scp work:/tmp/foo.txt ~/foo.txt&#8221; &#8212; you don&#8217;t have to remember the forwarded port numbers.</p>
<p>Typing &#8220;ssh work&#8221; is nine keystrokes (eight letters plus enter). If you can type 40 wpm, that&#8217;s 200 keystrokes per minute, or 3.33 keystrokes per second, which means you can open the tunnel in four seconds!</p>
<p>If you add &#8220;alias ssw=&#8217;ssh work&#8217;&#8221; to your ~/.bashrc, you&#8217;re down to four keystrokes.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/local-ssh-forwarding' rel='bookmark' title='Permanent Link: Use Local SSH Forwarding to Reduce the Number of Manual Hops'>Use Local SSH Forwarding to Reduce the Number of Manual Hops</a> <small>Local port forwarding is the same...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Local SSH Forwarding to Reduce the Number of Manual Hops</title>
		<link>http://blog.bstpierre.org/local-ssh-forwarding</link>
		<comments>http://blog.bstpierre.org/local-ssh-forwarding#comments</comments>
		<pubDate>Wed, 02 Dec 2009 15:12:19 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[ssh]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=219</guid>
		<description><![CDATA[Local port forwarding is the same as remote port forwarding but works in the opposite direction. An example is the clearest way to explain...


Related posts:<ol><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><em>(This is part three in a <a href="../category/tools/ssh">series of posts on ssh</a>.)</em></p>
<p>Local port forwarding is the same as <a title="How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels" href="http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels">remote port forwarding</a> but works in the opposite direction. An example is the clearest way to explain.</p>
<p>Assuming you&#8217;ve done the steps in the previous posts, then at home you can run &#8220;ssh -L 4022:localhost:4022 me@cloud.example.com&#8221;. This listens on TCP port 4022 on your home machine. Any connections there will be forwarded through the ssh connection to port 4022 on cloud&#8230; which, as we recall, gets forwarded to port 22 (ssh) at work. If you leave this connection open, you can run &#8220;ssh -p 4022 localhost&#8221; on your home machine and it will connect to work in just one hop. This means that you can use scp to copy files from home to work or vice versa. For example, &#8220;scp -P 4022 localhost:/tmp/foo.txt ~/foo.txt&#8221; will copy a file from work to home. (<em>Note: scp needs capital &#8220;-P&#8221; to give the port. I got it wrong the first time.</em>)</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/local-ssh-forwarding/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</title>
		<link>http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels</link>
		<comments>http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels#comments</comments>
		<pubDate>Tue, 01 Dec 2009 14:35:17 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[ssh]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=215</guid>
		<description><![CDATA[Ssh tunneling can be a bit mind bending at first, but it's simple when you get used to it.


Related posts:<ol><li><a href='http://blog.bstpierre.org/local-ssh-forwarding' rel='bookmark' title='Permanent Link: Use Local SSH Forwarding to Reduce the Number of Manual Hops'>Use Local SSH Forwarding to Reduce the Number of Manual Hops</a> <small>Local port forwarding is the same...</small></li><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><em>(This is part two in a <a href="http://blog.bstpierre.org/category/tools/ssh">series of posts on ssh</a>.)</em></p>
<p>Ssh tunneling can be a bit mind bending at first, but it&#8217;s simple when you get used to it. Assume that you&#8217;re trying to ssh between two sites that do not allow incoming ssh. Maybe your IT at work is unenlightened and doesn&#8217;t have an ssh gateway. And your ISP has braindead configuration rules that don&#8217;t allow incoming ssh or they make it difficult.</p>
<p>What you need to get around this is a server &#8220;in the cloud&#8221; that permits ssh logins. This could be a hosting server that you pay for, or even a friend with an enlightened ISP who will give you a login account.</p>
<p>On your work PC, use ssh to login to the &#8220;cloud&#8221; server. Using the &#8220;-R&#8221; argument, you tell ssh to listen on a TCP port on the cloud server. Any connection coming in to this server will be forwarded back through the ssh connection to the TCP port you specify. For example, on mymachine.work.com, &#8220;ssh -R 4022:localhost:22 me@cloud.example.com&#8221; tells ssh to listen on cloud&#8217;s port 4022. Incoming connections to that port on cloud will be forwarded to port 22 (ssh) on mymachine.</p>
<p>By default, ssh will only listen to port 4022 on cloud&#8217;s localhost interface. So to log in to work, you will first need to log into cloud, and then use &#8220;ssh -p 4022 myworklogin@localhost&#8221; to log into work.</p>
<p>We&#8217;ll work around this limitation in the next post in this series.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/local-ssh-forwarding' rel='bookmark' title='Permanent Link: Use Local SSH Forwarding to Reduce the Number of Manual Hops'>Use Local SSH Forwarding to Reduce the Number of Manual Hops</a> <small>Local port forwarding is the same...</small></li><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Tell SSH Who You Are</title>
		<link>http://blog.bstpierre.org/configure-ssh-username</link>
		<comments>http://blog.bstpierre.org/configure-ssh-username#comments</comments>
		<pubDate>Mon, 30 Nov 2009 15:11:10 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[ssh]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=222</guid>
		<description><![CDATA[Do you log in to several servers with different usernames via ssh? Save typing by telling ssh which username to use on each server.


Related posts:<ol><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Ssh has amazing capabilities that you probably aren&#8217;t using on a daily basis.</p>
<p>The capability that you probably aren&#8217;t using, and the easiest to use, is customizing your config file (in ~/.ssh/config) for the various servers you log into.</p>
<p>For example, I frequently log into about ten different servers using at least four different usernames. By default, if I type &#8220;ssh server&#8221; the client will use my login name on the client machine to try to log into the server &#8212; which is usually wrong. Instead you can <a href="http://superuser.com/questions/64996/how-to-make-ssh-log-in-as-the-right-user">tell your ssh client which username to use on each server</a>. (Thanks to <a href="http://wblinks.com/">Rich Adams</a> for the tip.)</p>
<p>You can customize a variety of settings &#8212; not just the username. For example, I specify a different identity file for a couple of servers.</p>
<p>This saves a bunch of typing and occasional confusion. (By avoiding login errrors as I try to log into a server using the wrong username and can&#8217;t figure out why my password isn&#8217;t working&#8230;)</p>
<p><em>(This is the first post in <a href="../category/tools/ssh">series of posts about how to get the most out of ssh</a>. Make sure you don&#8217;t miss the rest of the series: <a href="http://feeds2.feedburner.com/TheDailyBuild">subscribe to my feed</a> or <a href="http://twitter.com/bstpierre">follow me on twitter</a>.)</em></p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li><li><a href='http://blog.bstpierre.org/ssh-remote-port-forwarding-tunnels' rel='bookmark' title='Permanent Link: How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels'>How to Use SSH Remote Port Forwarding to Set Up Secure Tunnels</a> <small>Ssh tunneling can be a bit...</small></li><li><a href='http://blog.bstpierre.org/ssh-forward-multiple-protocols-to-multiple-machines' rel='bookmark' title='Permanent Link: Use SSH to Forward Multiple Protocols to Multiple Machines'>Use SSH to Forward Multiple Protocols to Multiple Machines</a> <small>Let's say you have a half-dozen...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/configure-ssh-username/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
