You need to have cygwin and its following packages installed
- make (
Devel group -> make
) - rsync (
Net group -> rsync
) - ssh (
Net group -> openSSH
)
NOTE: You may already have ssh installed due to git shell, or other shell installation, but make sure you install the cygwin version of ssh (openSSH)
If you already have cygwin installed, but not the packages, all you have to do is run the installation again, and select the packages when asked. If it's the same version of cygwin, ti will only install the packages.
Once you have met the requirements, you need to setup Cygwin so that it can ssh into your vagrant machine using the command ssh
. We usually access our machine using vagrant ssh
, but that won't let us use rsync
which relies on ssh
to connect to a remote server, in this case being our Vagrant machine.
In cygwin use the command vagrant ssh-config
in the root folder of your vagrant machine (where the Vagrantfile
is located) to get the necessary ssh configuration:
$ vagrant ssh-config
#OUTPUT:
Host default
HostName 127.0.0.1
User ubuntu
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile D:/Workspace/udacity/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
Copy the output and paste it in your ~/.ssh/config
file as follows:
Host udacity
HostName 127.0.0.1
User ubuntu
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile D:/Workspace/udacity/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
In this example I changed Host default
to Host udacity
to match the name of the vagrant machine, and to allow me to ssh into the vagrant machine using the command:
$ ssh ubuntu@udacity
If everything goes as expected, you should be able to login into your machine using the command ssh
from cygwin.
repository: https://github.com/thekid/inotify-win
inotify-win is a port of the inotifywait tool for Windows.
In cygwin, clone the inotofy-win repo, cd into it and then run make to compile it:
$ git clone https://github.com/thekid/inotify-win.git
$ cd inotify-win
$ make
#OUTCOME:
inotifywait.exe
I renamed inotifywait.exe
to inotifywait
and then moved it to the /usr/loacl/bin/
folder in cygwin (this is the first path in the $PATH
variable). You can place the executable anywhere, as long as it's available in $PATH. The shell script bellow needs access to inotifywait
I've created a shell script intended for Cygwin called autosync.sh.
Get it here: https://gist.github.com/AlexandroPerez/b749ed7c1255961794fb1f0d804fbe32
Inspect the code, download it and test it after this.
You'll need to make sure to add paths to .syncignore
that you don't want deleted from your remote vagrant machine. rsync
will delete in remote
anything that's not in the source
. To avoid this you'll have to add individual files and folders you want excluded to .syncignore
.
If you wan't to help providing .syncignore
examples for whatever work you perform, post a comment.
My
.syncignore
when I work with node.js and gulp