这是我第一次尝试bash脚本,我正在尝试将OS上的项目文件夹同步到运行ubuntu14.04的开发服务器上。当我试图作为我的用户'developer‘进行rsync时,我在目标服务器上得到了一些权限错误,但当我作为用户'ubuntu’执行时,我也得到了这些错误。由于EC2上的默认云服务器设置,我无法尝试作为root用户。
这是我的外壳脚本。
#!/bin/bash
rsync -r —l -t -z -v -e "ssh developer@xx.xxx.xx.xx" --exclude “/Applications/MAMP/htdocs/finalall/nbproject/” --delete /Applications/MAMP/htdocs/finalall/ :/var/www/html
afplay "/System/Library/Sounds/Morse.aiff"这是我的错误:
building file list ... rsync: link_stat "/Users/xxxxx/?\#200\#224l" failed: No such file or directory (2)
done
IO error encountered -- skipping file deletion
rsync: failed to set times on "/var/www/html/.": Operation not permitted (1)
./
rsync: recv_generator: mkdir "/var/www/html/nbproject" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
testerterst.php
nbproject/
rsync: mkstemp "/var/www/html/.testerterst.php.TISozV" failed: Permission denied (13)
sent 493 bytes received 54 bytes 1094.00 bytes/sec
total size is 971 speedup is 1.78
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]以下是sudo /etc/group的一些输出
ssh:x:108:
landscape:x:109:
admin:x:110:
ubuntu:x:1000:
ssl-cert:x:111:
developer:x:1001:衷心感谢您的帮助。这是非常,非常感谢。
对ls -lZd / /var/ /var/www/ /var/www/html/的输出是:
drwxr-xr-x 22 root root ? 4096 Aug 5 19:53 /
drwxr-xr-x 13 root root ? 4096 Aug 5 20:00 /var/
drwxr-xr-x 3 root root ? 4096 Aug 5 20:00 /var/www/
drwxr-xr-x 2 root root ? 4096 Aug 5 20:17 /var/www/html/发布于 2015-08-07 07:41:19
您无法对目标服务器上的/var/www/html进行写入访问,因为该文件夹属于根用户,其他人只具有读取/执行权限。
解决此问题的最佳方法是将该目录的所有者更改为ssh用户:
chown -R developer. /var/www/html这将/var/www/html及其所有子目录的所有者更改为开发人员用户及其默认组。
如果还有其他用户需要对同一个目录进行写访问,我建议将它们放在一个组中,然后更改文件夹的权限,以允许同一组中的每个人都具有写访问权限。下面的内容向你展示了如何做到这一点。
groupadd devs #Adds a group called devs
useradd -G devs ubuntu #Adds the devs group to the ubuntu user
chown -R .devs /var/www/html #Changes only the group of the directory to devs
chmod -R 775 /var/www/html #Allows the owner and group of the directory full access, everybody else only has read/executehttps://serverfault.com/questions/711427
复制相似问题