When working with restricted filesystems like SSHFS-mounted directories, you'll often encounter permission issues during rsync operations. The default behavior of rsync is to preserve file ownership (-o) and group (-g) attributes, which causes problems when you lack chown privileges on the target system.
Here's what typically happens during an rsync transfer to an SSHFS mount:
rsync -avz /local/path/ user@remote:/sshfs/mount/
This generates numerous chown: permission denied (error 13)
messages because:
- SSHFS presents files with the ownership of the connecting user
- Standard rsync tries to replicate source ownership attributes
- The underlying filesystem doesn't permit ownership changes
The simplest solution is to disable ownership preservation:
rsync -rlptDvz --no-owner --no-group /local/path/ user@remote:/sshfs/mount/
Key options explained:
--no-owner
: Skip ownership preservation--no-group
: Skip group preservation-r
: Recursive copy-l
: Preserve symlinks-p
: Preserve permissions-t
: Preserve timestamps-D
: Preserve devices/specials
For more granular control, you can specify permission behavior:
rsync -avz --chmod=ugo=rwX /source/ user@remote:/target/
This ensures files get appropriate permissions without attempting ownership changes.
When transferring thousands of files, add these optimizations:
rsync -rlptDvz --no-owner --no-group --info=progress2 \
--partial --inplace /massive_data/ user@remote:/backup/
- Verify SSHFS mount options (try
uid
andgid
parameters) - Check if target filesystem supports POSIX attributes
- Consider using
--fake-super
for extended attribute handling
Remember that while the errors are harmless in this context, eliminating them makes logs cleaner and transfer outputs more readable.
When working with SSHFS-mounted remote filesystems, you'll frequently encounter permission limitations where standard chown operations aren't permitted. This becomes particularly problematic with rsync transfers, as rsync by default attempts to preserve file ownership metadata.
sshfs user@remote:/path /mnt/remote
rsync -avz /local/path/ /mnt/remote/path/
# Results in numerous "chown: permission denied" errors
The solution lies in these critical rsync options:
rsync -rlptDvz --no-o --no-g --no-perms /source/ user@remote:/dest/
Breaking down the flags:
- -r: Recursive copy
- -l: Copy symlinks as symlinks
- -p: Preserve permissions
- -t: Preserve modification times
- -D: Preserve devices and special files
- --no-o: Exclude owner preservation
- --no-g: Exclude group preservation
For more granular control over permission preservation without ownership changes:
rsync -av --chmod=ugo=rwX --no-o --no-g source/ dest/
This sets permissions to 0666 for files and 0777 for directories while skipping ownership changes entirely.
If you have control over the SSHFS mount options, consider these parameters:
sshfs -o uid=$(id -u),gid=$(id -g),default_permissions user@host:/path /mnt/point
This forces all files to appear owned by your local user while maintaining original permissions on the remote system.