Use flock to avoid concurrent access to authorized keys.

We already use this code in Ontohub:
https://github.com/ontohub/ontohub/blob/master/lib/authorized_keys_manager.rb

cc @tillmo, @0robustus1, @nning, @eugenk