Rsync
在 ubuntu 伺服器之間使用 rsync:// 協議時,rsync 權限被拒絕
我正在嘗試使用
rsync://
協議將文件從 host2 同步到 host1(都執行 Ubuntu Server 20.04),而無需輸入任何密碼。在主機 2 上:
$ cat /etc/rsyncd.conf log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock [folder] path = /home/username comment = rsync folder read only = false list = yes
然後我跑
sudo systemctl start rsync
$ cat /var/log/rsyncd.log 2021/03/25 01:07:51 [8035] rsyncd version 3.1.3 starting, listening on port 873
在主機 1 上:
$ rsync /home/username/test.txt rsync://host2:/folder rsync: mkstemp "/.test.txt.UHerWZ" (in folder) failed: Permission denied (13) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
在主機 2 上:
$ tail -F /var/log/rsyncd.log 2021/03/25 03:13:00 [9212] name lookup failed for host1: Name or service not known 2021/03/25 03:13:00 [9212] connect from UNKNOWN (host1) 2021/03/25 03:13:00 [9212] rsync to folder/ from UNKNOWN (host1) 2021/03/25 03:13:00 [9212] receiving file list 2021/03/25 03:13:00 [9212] rsync: mkstemp "/.test.txt.KRLgUO" (in folder) failed: Permission denied (13) 2021/03/25 03:13:00 [9212] sent 122 bytes received 95 bytes total size 5
是什麼導致權限被拒絕?我需要在其中定義使用者名和密碼
/etc/rsyncd.conf
嗎?
預設情況下,當 rsyncd 以 root 身份執行時,它會
nobody
在傳輸之前更改為使用者。如果你的路徑/home/username
不屬於這個 id,等等,你會得到錯誤。通常,您需要添加一個 id 以在您的節中執行(並且通常還將組 id 設置為該使用者的預設值),如下所示:[folder] path = /home/username uid = username gid = * ...