remote: use better approach to upload remote helper
This change also prevents a race condition when the remote helper is run
concurrently. An attacker could use the small window when the old helper
gets removed to create a file which is then executed by the concurrent
run.
A few other approaches were considered. The main issue is the
uncertainty in the behavior of command line tools like `mv`. The system
calls have well defined behavior but it's not clear how exactly the
tools are implemented. The goal was to find an approach which is secure
even under these circumstances without having to validate them across
multiple operating systems.