rsync使用sudo权限

1、在etc/sudoers增加,比如www-data这个账户的

www-data ALL=NOPASSWD:/usr/bin/rsync

2、使用时增加--rsync-path="sudo rsync"

rsync -avh --rsync-path="sudo rsync" /etc/profiled.d/java.sh [email protected]:/etc/profiled.d/

参考:

https://superuser.com/questions/270911/run-rsync-with-root-permission-on-remote-machine

https://unix.stackexchange.com/questions/92123/rsync-all-files-of-remote-machine-over-ssh-without-root-user/92397#92397

猜你喜欢

转载自www.cnblogs.com/EasonJim/p/9655941.html