title: OSX and launchctl, rsync/ssh can't find key
body: <p>So I've been trying to write a launchctl daemon for rsync so that it backs up my laptop remotely every night.</p>
  <p>The launchctl daemon runs fine, it uses the root user to call rsync, and rsync is instructed to use ssh, and grab the key file from my user directory. Here's where it gets interesting. No matter what I do, ssh throws the following error: <code>rsync: Failed to exec ssh -i /Users/anthony/.ssh/id_rsa: No such file or directory (2)</code></p>
  <p>The key is indeed there. If I call ssh on its own from the command line, I can use that key from both my user account and the root account. I'm assuming this is something to do with launchctl's scope, or privileges? Below is the plist file that launchctl is using. I'd really appreciate some help on this.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
  &lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
      &lt;key&gt;UserName&lt;/key&gt;
      &lt;string&gt;root&lt;/string&gt;
      &lt;key&gt;Label&lt;/key&gt;
      &lt;string&gt;com.anthony.remoteBackup&lt;/string&gt;
      &lt;key&gt;RunAtLoad&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;KeepAlive&lt;/key&gt;
      &lt;false/&gt;
      &lt;key&gt;StartCalendarInterval&lt;/key&gt;
          &lt;dict&gt;
              &lt;key&gt;Hour&lt;/key&gt;
              &lt;integer&gt;23&lt;/integer&gt;
              &lt;key&gt;Minute&lt;/key&gt;
              &lt;integer&gt;00&lt;/integer&gt;
          &lt;/dict&gt;
      &lt;key&gt;ProgramArguments&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;/usr/bin/rsync&lt;/string&gt;
          &lt;string&gt;-azb&lt;/string&gt;
          &lt;string&gt;--exclude=.*&lt;/string&gt;
          &lt;string&gt;--exclude=.*/&lt;/string&gt;
          &lt;string&gt;--backup-dir=&quot;/home/anthony/Documents/Old Remote Backup/macbook_air/&quot;&lt;/string&gt;
          &lt;string&gt;--suffix=.old&lt;/string&gt;
          &lt;string&gt;--delete&lt;/string&gt;
          &lt;string&gt;--delete-excluded&lt;/string&gt;
          &lt;string&gt;-e &quot;ssh -i /Users/anthony/.ssh/id_rsa&quot;&lt;/string&gt;
          &lt;string&gt;/Users/anthony/Documents&lt;/string&gt;
          &lt;string&gt;anthony@remote_domain_name:&quot;/home/anthony/Documents/Remote Backups/macbook_air/&quot;&lt;/string&gt;
      &lt;/array&gt;
      &lt;key&gt;StandardOutPath&lt;/key&gt;
      &lt;string&gt;/tmp/remote_backup_test&lt;/string&gt;
      &lt;key&gt;StandardErrorPath&lt;/key&gt;
      &lt;string&gt;/tmp/remote_backup_test&lt;/string&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  <p>here is the standard error from remote_backup_test</p>
  <pre><code>rsync: Failed to exec ssh -i /Users/anthony/.ssh/id_rsa: No such file or directory (2)
  rsync error: error in IPC code (code 14) at /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54.120.1/rsync/pipe.c(86) [sender=2.6.9]
  rsync: connection unexpectedly closed (0 bytes received so far) [sender]
  rsync error: error in rsync protocol data stream (code 12) at /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54.120.1/rsync/io.c(453) [sender=2.6.9]
  </code></pre>