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 www-data@192.168.5.10:/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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM