Installing SSH & rsync on the Server
rsync is a brilliant little program that is fairly common in Linux. It is basically used to synchronize two folders or file systems and consists of a daemon/service running on the server machine and a small application running on the client machine.
The great thing about rsync is that it splits the file up into chunks and then copies over only the chunks that have changed. So let's say you changed the artist in the tag of an MP3, it will copy only the chunk that contains the change over. This makes it fast, efficient and very suited to backing up over the Internet.
So the first thing we need to do is install SSH and rsync on your server machine The best version of rsync for Windows is called cwRsync. The server package can be downloaded from SourceForge here. Install it normally and ensure that you check the option to install OpenSSH server.
You will need to do this as an administrator, since it will install two services—one for rsync and the other for OpenSSH. These are not started by default, so go to Start->Run and type in services.msc to bring up the services screen (Figure 1). Locate the services called Openssh SSHD and RsyncServer, start them and set the Startup Type for each one to be Automatic.
Figure 1: Service console showing OpenSSHD and rsync server
Next, we need to activate a user so that we can use it to log in. cwRsync should have installed a menu item in your Start Menu. Locate it and click on 05. Start a UNIX BASH Shell. Which will bring up a command line. Then type in activate-user.sh and you'll see the following response:
$ activate-user.sh ?############################### Activate a user for copssh ############################### Do you want to activate a (l)ocal or a (d)omain user [l/d] ?
Enter 'l' for local and the system will respond with a list of local users:
User accounts for \\WIGGUM ----------------------------------------------------------------------- Administrator ASPNET Guest HelpAssistant kevin sshd SUPPORT_388945a0 SvcwRsync Enter a user account for activation :
Now enter the user you wish to activate. In my case, I entered "Kevin" and pressed the Enter key. The user activation process will then prompt to enter a passphrase to use with key generation. But since we'll be using our own keys, as you'll see later, just hit the Enter key to let the user activation process finish up:
Generate a 2048-bit RSA key pair for public key authentication: A passphrase is similar to a password and is used to protect the private key. Good passphrases are 10-30 characters long, are not simple sentences or otherwise easily guessable (English prose has only 1-2 bits of entropy per character, and provides very bad passphrases), and contain a mix of upper and lowercase letters, numbers, and non-alphanumeric characters. NB! There is no way to recover a lost passphrase. If the passphrase is lost or forgotten, a new key pair must be generated Enter passphrase (empty for no passphrase): Enter same passphrase again: Private key is /home/kevin/.ssh/kevin /bin/activate-user.sh: line 110: ln: command not found A shortcut/symbolic link to your windows home directory is created (myh processed file: C:\Program Files\cwRsyncServer\home\kevin\.ssh\kevin processed file: C:\Program Files\cwRsyncServer\home\kevin\.ssh\kevin Activation process for kevin is completed. You may establish an ssh connection to this machine now. Press a key to continue ... kevin@wiggum / $
Note that the program also creates a 'home' directory for the user in C:\Program Files\cwRsyncServer\home\. This directory will be the same as your user name and will contain a subdirectory called .ssh, which will contain your keys we will generate later. The username should be the one that you normally log into Windows with, that has a strong password. This machine will be accessible to everyone from the Internet unless you set up good security!
Now we need to change the port number that SSH is listening on from 22 to 443. Leaving it on 22 is not generally a good idea because you will be subject to frequent hacking attempts, and 443 can be useful to us as you will find out later.
Browse to the file C:\Program Files\cwRsyncServer\etc\sshd_config. Open it with WordPad and near the top you should see a line that says Port 22. Change this to Port 443. Next, stop and restart the SSH service in the services console.
Now let's test the server. Load up PuTTY (still on the server machine) and connect to localhost, being sure to change the port to 443. You should now be presented with a warning about accepting the key into the cache. Accept this and you will be presented with the login prompt. Enter the name of the user you set up before and then type in your Windows password. If all is well, you will now see a DOS-style command prompt. Since this was just a test, you can close PuTTY for now.