I guess first post should be about how exactly did I make Hexo work with
rsync. Actually, after searching for ready to use solution in Google I tried few things and of course they didn’t work. Reason for that is that
rsync doesn’t really like Windows – it’s a typical Unix/Linux tool. You can of course make it work without Hexo command, but what I really wanted is to make it work like it was intended to work. Here’s what I did.
First of all, you need to get Cygwin. For those who don’t know it, Cygwin is a Linux “emulator” running on Windows (please, don’t quote me on that, I know it’s wrong). While installing, remember to select 2 packages:
openssh. After it’s done, you need to start bash shell that it gives. Now commands time.
This will generate SSH key that Cygwin will use to communicate with SSH server on the other side (I use rsync over SSH as oposed to rsync daemon, but it’s probably same). After giving your key a passphrase (or not) we need to upload it to server. Best case scenario: you can login using password. If so, you can simply issue:
$ ssh-copy-id user@host [-p port]
This way remote server will know who you are. If you can’t, read your public key using:
$ cat ~/.ssh/id_rsa.pub
Then paste it to your
~/.ssh/authorized_keys file on remote machine and you should be good to go.
Now the fun part, configuring Hexo. This is quite simple snippet:
deploy: type: rsync host: <hostname> port: <port> user: <login> root: <absolute path to folder for your blog>
No magic here. Now from Cygwin shell, you can execute:
$ hexo generate $ hexo deploy
And… It might not work because
rsync or rather OpenSSH that is under it, doesn’t like easy access to your private key. There is an easy fix to it. First you need to change group for key file (we execute these in Cygwin):
$ chgrp Users ~/.ssh/id_rsa
This might be tricky as
Users is only valid in English Windows. If you have different language, you need to adjust it, for example, in Polish, that command would be:
$ chgrp Użytkownicy ~/.ssh/id_rsa
Next thing is to change permissions themselves. This should do the trick:
$ chmod 600 ~/.ssh/id_rsa
After all of that work, you can now execute
hexo deploy again and be a happy owner of easy to deploy Hexo blog.
One thing that I couldn’t make to work is permissions on remote side. Whenever I push my changes, I have to execute:
$ ssh user@host chmod -R a+rx DIR_WITH_BLOG
I still have no idea how to fix it, but it’s good enough workaround for now.No Comments on Hexo and Rsync on Windows