<?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>Pascal's blog &#187; ssh</title>
	<atom:link href="http://blog.dreamdevil.com/index.php/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dreamdevil.com</link>
	<description></description>
	<lastBuildDate>Tue, 02 Feb 2010 13:21:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Remote Desktop through SSH with PuTTY and Tomato firmware</title>
		<link>http://blog.dreamdevil.com/index.php/2008/09/06/remote-desktop-through-ssh-with-putty-and-tomato-firmware/</link>
		<comments>http://blog.dreamdevil.com/index.php/2008/09/06/remote-desktop-through-ssh-with-putty-and-tomato-firmware/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 14:00:46 +0000</pubDate>
		<dc:creator>Pascal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[PuTTY]]></category>
		<category><![CDATA[Remote Access]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Tomato firmware]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.dreamdevil.com/index.php/2008/09/06/remote-desktop-through-ssh-with-putty-and-tomato-firmware/</guid>
		<description><![CDATA[
****** UPDATE 2009/01/12
Fix on the port numbers used as example.  Port numbers must not be bigger than 65535. 
Thanks Mike for noting this.
************************
First of all, for simplicity, let&#8217;s assume we have a desktop at home that we want to connect to (control remotely) using a laptop while we are at a friend&#8217;s home. We will use [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Tomato SSH Deamon Configuration" href="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/tomato-configuration.png"></a></p>
<p>****** UPDATE 2009/01/12</p>
<p>Fix on the port numbers used as example.  Port numbers must not be bigger than 65535. </p>
<p>Thanks Mike for noting this.</p>
<p>************************</p>
<p>First of all, for simplicity, let&#8217;s assume we have a desktop at home that we want to connect to (control remotely) using a laptop while we are at a friend&#8217;s home. We will use Remote Desktop to connect from the laptop to the home desktop. The home network is behind a router (firewall) compatible with Tomato (ex: Linksys WRT54GL).</p>
<p>Remote Desktop is a server application that uses TCP/IP network to enable remote control of a machine. It opens the port 3389 to handle network communications. By default Remote Desktop is disabled on Windows XP.</p>
<p>How to enable Remote Desktop on Windows XP (on the home desktop):</p>
<table border="0">
<tbody>
<tr>
<td valign="top">
<ul>
<li>Start the system properties in the Control Panel (or right click &#8220;My Computer&#8221; and click properties).</li>
<li>Go to the &#8220;Remote&#8221; tab.</li>
<li>Enable remote desktop by checking &#8220;Allow users to connect remotely to this computer&#8221;.</li>
</ul>
<p style="border-top: 1px dotted; margin-top: 5px; font-size: 10px; padding-top: 5px; font-style: italic; font-family: Arial, Helvetica, sans-serif">Note 1: Don&#8217;t forget to set a password on the user you intend to use to connect remotely because Remote Desktop will prevent connection with blank passwords.</p>
<p style="font-size: 10px; font-style: italic; font-family: Arial, Helvetica, sans-serif">Note 2: By defaut, only users with the administrative priviledges are allowed to connect remotely.</p>
</td>
<td valign="top"><a title="Enable Remote Desktop on Windows XP" href="/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/enable-remotedesktop.png" target="_blank"><img src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/enable-remotedesktop.thumbnail.png" alt="Enable Remote Desktop on Windows XP" /></a></td>
</tr>
</tbody>
</table>
<p>At this point, Windows can handle remote connections.  In order to do it through the Internet you could simply forward the port 3389 from your router to the actual machine but at the same time you would expose your machine to the whole world. If you can do it, somebody else can try too.</p>
<p>Instead, we use a 3rd party firmware (called <a title="Tomato firmware official site" href="http://www.polarcloud.com/tomato" target="_blank">Tomato</a>) on the Linksys router. This firmware allows us to connect using SSH (a secured command line shell).</p>
<p>With SSH we can create encrypted communication links (called Tunnels) between the laptop and the router. SSH protocol requires a server that will also open a listening port. We need to login to this server to establish the SSH connection and create tunnels.</p>
<p>Why this instead of just opening Remote Desktop port (3389)?</p>
<ul>
<li>Because we will use a *different password* (will we? well we should&#8230; and a strong one!) than the one on your computer.</li>
<li>If we would have multiple computers to remote desktop to, we wouldn&#8217;t need to open additional ports, just create additional tunnels instead.</li>
<li>If somebody cracks our router password, he is still limited in he can do, he has to guess/find our machine and crack its password.</li>
<li>We can make SSH connection more secured by using a key file. This file is needed to establish the connection link, so another level of difficulty for a pirate&#8230;</li>
<li>The communication is encrypted between the two ends of the Tunnels (more privacy)</li>
</ul>
<p>So how to enable the SSH Server on the Tomato firmware?</p>
<p> </p>
<table border="0">
<tbody>
<tr>
<td valign="top">
<ul>
<li>Login to Tomato&#8217;s web interface</li>
<li>Go to Administration / Admin Access</li>
<li>In SSH Deamon section, set the following :
<ul>
<li>Enable at startup: checked</li>
<li>Remote access: checked</li>
<li>Remote port: &lt;choose one&gt;<br />
(ex: 5555 &#8212; used from Internet)</li>
<li>Port: 22<br />
(used from inside the LAN)</li>
<li>Authorized Keys: &lt;empty&gt;<br />
(for simplicity of this post)</li>
</ul>
</li>
</ul>
<p style="border-top: 1px dotted; margin-top: 5px; font-size: 10px; padding-top: 5px; font-style: italic; font-family: Arial, Helvetica, sans-serif">Note: Even if the screenshot shows this, we should use a different port than 22 (or 2222). If somebody discover our machine using a port scanner, he will have to guess what is the protocol (is it SSH, RDP, HTTP, FTP, etc?). If we leave the default, the guess is easy.</p>
</td>
<td valign="top"><a title="Tomato SSH Deamon Configuration" href="/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/tomato-configuration.png" target="_blank"><img src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/tomato-configuration.thumbnail.png" alt="Tomato SSH Deamon Configuration" /></a></td>
</tr>
</tbody>
</table>
<p>The home computer is enabled for remote desktop and the router is configured for SSH. Now we need to establish the SSH connection/tunnels, so put the laptop on the backpack and let&#8217;s ride to our best friend! Since the laptop is also running Windows XP, we are going to use PuTTY, an open source SSH client software (download it here).</p>
<p>Let&#8217;s configure PuTTY:</p>
<table border="0">
<tbody>
<tr>
<td valign="top">
<ul>
<li>Start PuTTY and fill the information of the first tab:
<ul>
<li>Host name or IP Address: &lt;enter yours&gt;</li>
<li>Port: &lt;the port you set earlier&gt;<br />
(ex: 5555)</li>
</ul>
</li>
</ul>
</td>
<td valign="top"><a title="PuTTY - Session Tab" href="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-connection.png"><img src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-connection.thumbnail.png" alt="PuTTY - Session Tab" /></a></td>
</tr>
<tr>
<td valign="top">
<ul>
<li>Configure tunnels in Connections / Tunnels tab:
<ul>
<li>Enter a source port: &lt;choose&gt;<br />
(ex: 15338)</li>
<li>Enter a destination address and port: &lt;ip&gt;:&lt;port&gt;<br />
(ex: 192.168.1.15:3389)</li>
<li>Local: Checked</li>
<li>Auto: Checked</li>
<li>Click add button</li>
</ul>
</li>
</ul>
<p style="border-top: 1px dotted; margin-top: 5px; font-size: 10px; padding-top: 5px; font-style: italic; font-family: Arial, Helvetica, sans-serif">Note: The destination address and port is the address of our home desktop which is often in the range of 192.168.x.x depending on the router.  Our Linksys uses 192.168.1.x range by default.  IP address could be anything within the range when address is assigned by a DHCP server.  To make sure the desktop computer always have the same IP address, we can set a fixed address or configure Tomato DHCP server to always assign the same (<a title="Configuring LAN host names with Tomato" href="/index.php/2008/08/13/tomato-firmware_remote-desktop-through-ssh_using-wake-on-lan_configuring-lan-hostnames/">see this post</a>)</p>
</td>
<td valign="top"><a title="PuTTY - Tunnel Creation" href="/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-tunnel-01.png" target="_blank"><img src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-tunnel-01.thumbnail.png" alt="PuTTY - Tunnel Creation" /></a><br />
<a title="PuTTY - Tunnel Creation" href="/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-tunnel-02.png" target="_blank"><img style="margin-top: 3px" src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-tunnel-02.thumbnail.png" alt="PuTTY - Tunnel Creation" /></a></td>
</tr>
</tbody>
</table>
<p>When we are going to open the SSH connection, PuTTY will open a local port defined by &#8220;source port&#8221;.  All the communication to that port will be encrypted and forwarded on the LAN to the destination address and port specified (ex: 192.168.1.15 port 3389).</p>
<p>Now let&#8217;s login to SSH Server</p>
<table border="0">
<tbody>
<tr>
<td valign="top">
<ul>
<li>Click the Open button, a black screen should appear.</li>
<li>We now have to enter the router&#8217;s username and password</li>
</ul>
</td>
<td valign="top"><a title="PuTTY - Login" href="/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-login-01.png" target="_blank"><img src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-login-01.thumbnail.png" alt="PuTTY - Login" /></a><br />
<a title="PuTTY - Login" href="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-tunnel-02.png"></a><a title="PuTTY - Login" href="/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-login-02.png" target="_blank"><img style="margin-top: 3px" src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-login-02.thumbnail.png" alt="PuTTY - Login" /></a><a title="PuTTY - Login" href="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/putty-tunnel-02.png"></a></td>
</tr>
</tbody>
</table>
<p>The only step left is to run Remote Desktop Connection software on the laptop:</p>
<table border="0">
<tbody>
<tr>
<td valign="top">
<ul>
<li>Open up remote desktop and specify the computer:
<ul>
<li>localhost:&lt;source port&gt;<br />
(ex: localhost:15338)</li>
</ul>
</li>
<li>Click connect</li>
</ul>
</td>
<td valign="top"><a title="Remote Desktop Login" href="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/rdp-login.png"><img src="http://blog.dreamdevil.com/media/2008/remote-desktop-through-ssh-with-putty-and-tomato-firmware/rdp-login.thumbnail.png" alt="Remote Desktop Login" /></a></td>
</tr>
</tbody>
</table>
<p>Voilà  we are now controlling the home desktop from outside the house using the laptop!</p>
<p>Specifications of the software used in this post:</p>
<table border="1">
<tbody>
<tr>
<td>Tomato firmware version</td>
<td>1.21.1515</td>
</tr>
<tr>
<td>PuTTY version</td>
<td>0.60</td>
</tr>
<tr>
<td>Windows version</td>
<td>Windows XP Service Pack 3</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.dreamdevil.com/index.php/2008/09/06/remote-desktop-through-ssh-with-putty-and-tomato-firmware/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Tomato firmware: Remote desktop through SSH, using Wake-On-Lan and configuring LAN Hostnames</title>
		<link>http://blog.dreamdevil.com/index.php/2008/08/13/tomato-firmware_remote-desktop-through-ssh_using-wake-on-lan_configuring-lan-hostnames/</link>
		<comments>http://blog.dreamdevil.com/index.php/2008/08/13/tomato-firmware_remote-desktop-through-ssh_using-wake-on-lan_configuring-lan-hostnames/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 03:34:28 +0000</pubDate>
		<dc:creator>Pascal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Dynamic DNS]]></category>
		<category><![CDATA[PuTTY]]></category>
		<category><![CDATA[Remote Access]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Tomato firmware]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[wol]]></category>

		<guid isPermaLink="false">http://blog.dreamdevil.com/index.php/2008/08/13/tomato-firmware_remote-desktop-through-ssh_using-wake-on-lan_configuring-lan-hostnames/</guid>
		<description><![CDATA[Hi,
I&#8217;ve been using 3rd party firmware for my Linksys WRT54GL router for some time.  I&#8217;ve used DD-WRT, OpenWRT and finally Tomato.   I switched from DD-WRT (for a reason I can&#8217;t remember) to go with OpenWRT.  I learned a lot on OpenWRT and really like their Kamikaze version.  The work they did for making it more [...]]]></description>
			<content:encoded><![CDATA[<p align="left">Hi,</p>
<p align="left">I&#8217;ve been using 3rd party firmware for my Linksys WRT54GL router for some time.  I&#8217;ve used <a title="DD-WRT Official Website" href="http://www.dd-wrt.com" target="_blank">DD-WRT</a>, <a title="OpenWRT Official Website" href="http://openwrt.org/" target="_blank">OpenWRT</a> and finally <a title="Tomato Firmware Official Website" href="http://www.polarcloud.com/tomato" target="_blank">Tomato</a>.   I switched from DD-WRT (for a reason I can&#8217;t remember) to go with OpenWRT.  I learned a lot on OpenWRT and really like their Kamikaze version.  The work they did for making it more like a standard distribution (no more NVRAM variables) is really cool.  Finally I recently moved to Tomato because of the lack of User Interface of OpenWRT (Yes I could use X-WRT but I tried it before and prefered to explore Tomato&#8230;).  When I feel lazy I prefer to use a GUI than go to the CLI&#8230;</p>
<p align="left">Now that I am more familar with my WRT (thanks to OpenWRT and all its documentation), it has been pretty easy to configure Tomato (firmwares are different, but in the end, they often use the same tools&#8230; busybox, dnsmasq, etc.).  I have some specific needs that drove me to install a 3rd party firmware in the first place:</p>
<ol>
<li>
<p align="left">I need to be able to access my computers from the internet using remote desktop</p>
</li>
<li>
<p align="left">But I don&#8217;t want to leave my computers open all day long for nothing, so I need to be able to use Wake-On-Lan to power them up remotely</p>
</li>
<li>
<p align="left">I don&#8217;t want to open remote desktop port (3389) on the firewall</p>
</li>
<li>
<p align="left">I want to use DHCP server, but I need to set some specific address (static DHCP) on some computers<br />
(so port forwarding is always configure correctly for my P2P machine&#8230;)</li>
<li>
<p align="left">I need to be able to use the same domain name (ex: mysite.dyndns.org) with my laptop no matter if I connected to my LAN or to a public network (through the Internet)</p>
</li>
</ol>
<p align="left">My Solution:</p>
<table style="text-align: left" border="1">
<tbody>
<tr>
<td><strong>Feature</strong></td>
<td><strong>Tomato Configuration</strong></td>
</tr>
<tr>
<td valign="top">Access my computers from the internet using remote desktop.</td>
<td valign="top">
<ol>
<li>I setup an account with dynDNS. It is free up to 5 domain names (if I remember correctly).This account allows me to use a software to update a domain name with my new IP address when my ISP changes it. From the internet I can just connect to my router using example.dyndns.org.Most routers supports dynDNS (and some others as well) natively.</li>
<li>I enabled the SSH Deamon<br />
(Administration / Admin access)Enabled at Startup: checked<br />
Remote Access: checked<br />
Remote Port: [your choice]<br />
Allow Password Login: checked</li>
<li>When I want to connect to my computers, I use a SSH client software (PuTTY) to connect to my router.PuTTY allows me to configure SSH Tunnels so I can redirect a local port to a remote machine on my LAN without opening any additionnal ports.</li>
</ol>
</td>
</tr>
<tr>
<td valign="top">I need to power up my computers only when needed.</td>
<td valign="top">This requires the Wake-On-Lan feature.Most modern computer has this feature (My old Pentium 2 266Mhz had it back in 1998) but you usually have to turn the feature ON in your computer BIOS because it is often disabled by default.When you want to power-up a computer, all you need is its mac address (in Windows, you can find it by running IPCONFIG at the command line) and a software that will broadcast a &#8220;magic packet&#8221; on your LAN.Tomato has a built-in software called <span style="text-decoration: underline;">ether-wake</span> that does the job.<span style="text-decoration: underline;">My configuration is like this:</span>On startup of the router, generate a file called wakeup-mycomputer.sh that will be placed in the root home directory. This file will contain the command able to wake-up the computer you want.</p>
<p>Then when you logon to your router using SSH (from the LAN or the Internet), you can issue this command &#8220;sh wakeup-mycomputer.sh&#8221; and you&#8217;re done.</p>
<p>You wait a little bit (until your computer responds to ping) and use the steps of the previous feature to connect remotely&#8230;</p>
<p><span style="text-decoration: underline;">How to achieve this:</span></p>
<ol>
<li>In the Initialization script of the firmware (Administration / Scripts / Init tab), type this:<br />
<code>echo "/usr/bin/ether-wake 01:23:45:67:89:AB" &gt; /tmp/home/root/wakeup-mycomputer.sh</code><br />
(change 01:23:45:67:89:AB to the mac address of the computer you want to wake-up)</li>
<li>Save and reboot the router, you should see the file &#8220;wakeup-mycomputer.sh&#8221; appear in the root home directory when you connect using SSH.</li>
<li>Try it &#8220;sh wakeup-mycomputer.sh&#8221;</li>
</ol>
<p>Note: for the wake-on-lan to work, the computer must have been turn off (soft off). After a power outage or a hard off (unplug, press power off for 5 seconds) the wake-on-lan may not work. Just turn on the computer manually and perform a shutdown.</p>
<p>Note2: I found out that some Linux distribution does not &#8220;soft off&#8221;. With Ubuntu 8.04, for example, I needed to add a command in the shutdown script&#8230; can&#8217;t remember. Just post a comment if you want me to digg it again&#8230;</td>
</tr>
<tr>
<td valign="top">Configure static DHCP addresses.</td>
<td valign="top">This is easy, just navigate to the Tomato &#8220;Basic / static DHCP&#8221; menu item. Use the mac address of the computer you want a fix address and the address you want for it.</td>
</tr>
<tr>
<td valign="top">Use the same domaine name inside the LAN and outside (from the Internet).</td>
<td valign="top">
<p align="left">When I am connected from the Internet, my domain &#8220;example.dyndns.org&#8221; resolve to my router public address which forward the port to the right LAN machine.When I am on the LAN, I want to be able to connect using &#8220;example.dyndns.org&#8221;. But if this domaine resolve to the public address of the router while you are already in the LAN, it does not work. To correct the problem, you could use a host file on your LAN computers, but when you have a laptop that is sometimes on the LAN, sometimes on an external network, you would need to enable/disable your host file every time&#8230;The way I succeed to anwer my need, is by providing a host file to the router. I found 2 ways with the Tomato firmware:</p>
<p align="left"><span style="text-decoration: underline;">First way</span> is explained here on <a title="How to add hostnames that can be used inside my LAN" href="http://www.polarcloud.com/tomatofaq#how_do_i_add_hostnames_that_i_" target="_blank">Tomato FAQ</a>.  Unfortunately, I needed to provide multiple host names (domain name) to the same IP address, you can do it by separating them with a space, but Tomate host name field is not wide enough for me.</p>
<p align="left"><span style="text-decoration: underline;">So my solution goes like this:</span></p>
<ol>
<li>Create a host file with my ip / host bindings at router boot time (before firewall is started).<br />
In &#8220;Administration / Scripts&#8221; menu item, on &#8220;Init&#8221; tab, place the following lines (use your IP addresses and domain names):<br />
<code>echo "192.168.1.xxx  example.dyndns.org" &gt; /tmp/hosts.local<br />
echo "192.168.1.yyy  example2.dyndns.org" &gt;&gt; /tmp/hosts.local</code></li>
<li>Configure the firewall (dnsmasq) to use this additional host file.<br />
In &#8220;Advanced / DHCP/DNS&#8221; menu item, in custom configuration, place this to enable your custom host file:<br />
<code>addn-hosts=/tmp/hosts.local</code></li>
<li>Save and reboot the router.</li>
<li>Test by doing a ping of you domain names (ping example.dyndns.org).<br />
The result should be your configured local IP addresss, not the router&#8217;s public IP address.</li>
</ol>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.dreamdevil.com/index.php/2008/08/13/tomato-firmware_remote-desktop-through-ssh_using-wake-on-lan_configuring-lan-hostnames/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
	</channel>
</rss>
