2
votes

There are many posts about this on the web but I have not found a working solution for my issue.

I'm on Mac OS Catalina. I have written a script to rsync a remote directory, via ssh, to my local computer:

#!/bin/bash
/usr/bin/rsync -arvzhe --delete 'ssh -i /Users/myusername/.ssh/id_rsa' [email protected]:/home/storage/app/public /Users/myusername/public/

But it fails with the error:

Permission denied (publickey). rsync: connection unexpectedly closed (0 bytes received so far) [receiver] rsync error: error in rsync protocol data stream (code 12) at /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54/rsync/io.c(453) [receiver=2.6.9]

The rsync call works fine when calling manually from the Terminal.

I do have a private key file in /Users/myusername/.ssh/id_rsa

Thanks.

1

1 Answers

0
votes

You have to give your terminal app full disk access. (It will still have to obey Unix-level permissions after you do, but right now you are bumping into another layer of security that Mac OS has added.)

To fix, go to: System Preferences => Security and Privacy => Privacy, select "Full Disk Access" and check the "Terminal" box on the right.