title: How to write a string to a file on a remote machine?
body: <p>On Machine1, I have a Python2.7 script that computes a big (up to 10MB) binary string in RAM that I'd like to write to a disk file on Machine2, which is a remote machine.  What is the best way to do this?  </p>
  
  <p>Constraints:</p>
  
  <ul>
  <li><p>Both machines are Ubuntu 13.04.  The connection between them is fast -- they are on the same network.</p></li>
  <li><p>The destination directory might not yet exist on Machine2, so it might need to be created.</p></li>
  <li><p>If it's easy, I would like to avoid writing the string from RAM to a temporary disk file on Machine1.  Does that eliminate solutions that might use a system call to rsync?</p></li>
  <li><p>Because the string is binary, it might contain bytes that could be interpreted as a newline.  This would seem to rule out solutions that might use a system call to the echo command on Machine2.</p></li>
  <li><p>I would like this to be as lightweight on Machine2 as possible.  Thus, I would like to avoid running services like ftp on Machine2 or engage in other configuration activities there.  Plus, I don't understand security that well, and so would like to avoid opening additional ports unless truly necessary.</p></li>
  <li><p>I have ssh keys set up on Machine1 and Machine2, and would like to use them for authentication.</p></li>
  <li><p>EDIT: Machine1 is running multiple threads, and so it is possible that more than one thread could attempt to write to the same file on Machine2 at overlapping times.  I do not mind the inefficiency caused by having the file written twice (or more) in this case, but the resulting datafile on Machine2 should not be corrupted by simultaneous writes.  Maybe an OS lock on Machine2 is needed?</p></li>
  </ul>
  
  <p>I'm rooting for an rsync solution, since it is a self-contained entity that I understand reasonably well, and requires no configuration on Machine2.</p>