Tuesday, March 28, 2006

WinXP to WinXP Remote Desktop over the internet via SSH tunnels

I decided I should type out some how-to's on some cool things before I forget how I did it. Maybe someone else might find these useful too.

How to use Remote Desktop over the internet through SSH tunneling.

Requirements:

1. Windows XP Professional
2. SSH server and client (I use Cygwin with OpenSSH)

3. Broadband internet connection (we're displaying an entire desktop over the internet, not just text!)


Steps:
1. Setup a dynamic DNS forwarding address
2. Download and install Cygwin with the OpenSSH packages
3. Setup SSH server and open port 22 on firewall.
4. Make sure Remote Desktop is turned on and you can use it
5. Create a reverse SSH tunnel
6. Connect with remote desktop

Procedure:
1. Setup a dynamic DNS forwarding address
If you want to remember your IP address in order to connect to your computer you can skip this step but as for me, I wanted a simple web-style address that I could remember that would update if my IP changed. I used dyndns.com to create a name that would be easy to remember in order to login to my SSH server. You can setup an account with them for free and it allows you to alias a dynamic IP address to a static hostname.

2. Download and install Cygwin with the OpenSSH packages
Download and install Cygwin on both computers (the computer you want to connect to and the one you want to connect from.) When installing Cygwin, the default only installs minimum packages. I like to install all packages so click where it says "Default" and it will say "Install". This way it will install ALL packages. Installing Cygwin with all packages will take a while (even WITH the broadband connection) so go find something to do for a while.

3. Setup SSH server and open port 22 on firewall.
After installing Cygwin, set it up with the mkpasswd and mkgrp commands. Run ssh-host-config to setup the SSH server on the computer you want to connect to. I usually just go with the default responses. Answer yes to the key generation question and yes to install it as a service. After the ssh-host-config program finishes running, type "cygrunsrv -S sshd" to start the service. Open port 22 on your firewall and/or router.

4. Make sure Remote Desktop is turned on and you can use it
Make sure you have enabled Remote Desktop by right clicking on the "My Computer" icon and enabling Remote Desktop in the "Remote" tab. Click on "Select Remote Users" and make sure you have an account that is allowed to remotely connect.

5. Create a reverse SSH tunnel
Assuming you've successfully setup the SSH server you're now ready to connect! On your remote computer, (this could be at work, school, etc.; basically, anywhere with a high speed internet connection where you want to Remote Desktop to your home computer), open up a Cygwin prompt and connect to your SSH server like this:
"ssh -L 3390:localhost:3389 username@servername"
Accept the key and enter your password to connect.

6. Connect with remote desktop
Don't close the Cygwin window or else the tunnel will collapse. Open Remote Desktop (Programs->Accessories->Communications->Remote Desktop Connection) and connect to 127.0.0.1:3390
Login to your computer!

1 comment:

Mike said...

Sound cool, but complicated.