I want to use rsync to deploy a project from my dev machine (Windows 11, CygWin) to a remote server (Ubuntu) through SSH. I've made sure that my SSH user has full write access to the destination folder by running the commands below:
root# mkdir /opt/my-project
root# chmod +rwx /opt/my-project
root# cwown -R ubuntu /opt/my-project
ubuntu$ touch /opt/my-project/test && rm /opt/my-project # No errors
On my Windows machine, I am using the following rsync command:
C:\cygwin64\bin\rsync.exe -Pav \
-e "C:/cygwin64/bin/ssh.exe -i <SSH Key File>" \
./bin/Release/net6.0/linux-x64/publish/ ubuntu@my_server:/opt/my-project/
I would expect this command to start an incremental file synchronization, and upload all the missing files to the project folder on the server. But instead, the rsync tool spits out a bunch of Permission denied (13)
errors and fails to copy a single file. On top of that, when I go back to the server to check the target folder, the ubuntu
user no longer has any form of access to it. Even listing the folder (ls /opt/my-project
) gives a Permission denied error.
This is a very strange behavior, because prior to the upload, the ubuntu
user definitely has full write access to the target folder, but it seems like rsync intentionally locks itself out of the folder before transferring a single file.
Here's the shortened output of the rsync command:
sending incremental file list
rsync: failed to modify permissions on "/opt/my-project/.": Permission denied (13)
rsync: recv_generator: failed to stat "/opt/my-project/file1.so": Permission denied (13)
rsync: recv_generator: failed to stat "/opt/my-project/file2.so": Permission denied (13)
...
rsync: recv_generator: mkdir "/opt/my-project/file420.so" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
...
sent 71,147 bytes received 53,278 bytes 49,770.00 bytes/sec
total size is 314,634,345 speedup is 2,528.71
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=3.2.4dev]
What's causing this behavior?
Rsync and OS versions:
- Local: Windows 11, CygWin/rsync version 3.2.4dev protocol version 31
- Remote: Ubuntu 20.04, rsync version 3.1.3 protocol version 31