Deployment Simple for Servers multiple on Files Synchronize to Linux and Cygwin with Windows on Unison Install
Unison is the best program I have found to synchronize files between
a Windows System and a Linux System.
Unison needs ssh, So i give you the following instruction how to install ssh on Windows and Linux and how to synchronize between the two machines.
Install Unison on Linux System
Unison has to be installed on server1 and server2; since we connect from server1 to server2 using SSH, we also need the SSH packages. This can be achieved as follows:
apt-get install unison openssh-server ssh
Creating A Private/Public Key Pair On server1
Now we create a private/public key pair on server1
ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): <-- ENTER
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): <-- ENTER
Enter same passphrase again: <-- ENTER
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
1b:95:bc:4a:f4:9f:d8:ea: 24:31:0f:c9:72:d5:a7:80 email@example.com
The key's randomart image is:
+--[ DSA 1024]----+
| o s |
| E * . . |
| o = o o |
| . S od . |
| + O + . |
| + + + |
| o . |
| .o |
It is important that you do not enter a passphrase otherwise the mirroring will not work without human interaction so simply hit ENTER!
Next, we copy our public key to server2
ssh-copy-id -i $HOME/.ssh/id_dsa.pub firstname.lastname@example.org
The authenticity of host '192.168.1.101 (192.168.1.101)' can't be established.
RSA key fingerprint is
Are you sure you want to continue connecting (yes/no)? <-- yes (you will see this only if this is the first time you connect to server2)
Warning: Permanently added '192.168.1.101' (RSA) to the list of known hosts.
email@example.com's password: <-- server2 root password
Now try logging into the machine, with "ssh 'firstname.lastname@example.org'", and check in:
to make sure we haven't added extra keys that you weren't expecting.
Install Unison on Windows System
1. Download cygwin (http://cygwin.com/setup.exe).
2. Create a directory in c:\ call it "cygwin" and put setup.exe in there.(run that as admin)
3. Search for openssh and click on skip to change it to newest version.
4. On OpenSSH make sure under B the box it checked.
5. Search for unison and click on newest version.
6. On unison make sure under B the box it checked.
7. Click the start button, right click on Computer and select properties, click Advanced system setting, on the advanched tab click Environment Variables.
8. Under System Variables find "Path" and edit.
9. In Variable value add to the end.(No quotes just whats in them) ";c:\cygwin\bin"
10. On your desktop right click and run as administrator Cygwin Terminal.
11. cd ..
11. Run these commands in the terminal. One at a time
mkgroup -l > /etc/group
mkpasswd -l > /etc/passwd
chmod +r /etc/passwd
chmod u+w /etc/passwd
chmod +r /etc/group
chmod u+w /etc/group
chmod 755 /var
chmod 664 /var/log/sshd.log
12. Now run "ssh-host-config" when you reach the question
" Enter the value of CYGWIN for the daemon:" enter "ntsec tty".Answer all questions
with yes except "This script plans to use cyg_server, Do you want to use a different name?" enter yes and put the
name as "sshd".Then make up a password for that account.
13. Run "cyglsa-config". Anwser Yes to the question.
14.VERY IMPORTANT STEP REBOOT YOUR COMPUTER.
15. Open a Windows command prompt as administrator and run "cd C:\cygwin\bin"
16. Run "ash" then "/usr/bin/rebaseall"
17. Open your cygwin terminal as admin and type these commands.
chown system /etc/ssh*
chown system /var/empty
18. In the start menu type services.msc and find the "CYGWIN sshd" right click and properties.
On the log ON tab click "Local System Account" and check the box underneath.
Big Thanks to http://pigtail.net/LRP/printsrv/cygwin-sshd.html
We can now run Unison for the first time to synchronize the /var/www directory on both servers. On server1 run:
unison /var/www ssh://192.168.1.101//var/www
Synchronize between Linux machines:
Of course, we don't want to run Unison interactively, therefore we can create a preferences file (/root/.unison/default.prf) that contains all settings that we otherwise would have to specify on the command line:
edit the file and insert following:
# Roots of the synchronization
root = /var/www
root = ssh://192.168.1.101//var/www
Synchronize between Linux and Windows machines:
# Roots of the synchronization
root = /var/www
root = ssh://email@example.com///cygdrive/c/public/var/www
to run it with the profil, do following:
or you have another file for example server1.prf so start it with
don't forget to open the port 22 for ssh in local subnet.