• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

linux 一键配置rsync服务器脚本

服务器 开心洋葱 1534次浏览 0个评论

1、保存下面的代码为一个文件,上传到服务器端,名称为rsync.sh

  1. #!/bin/bash
  2. #rsync Written by zhumaohai
  3. #For more information please visit https://www.centos.bz
  4. echo “Please input the rsync username:”
  5. read username
  6. echo “Please input the rsync username password:”
  7. read password
  8. echo “Please input the allow ip address:”
  9. read allowip
  10. echo “Please input the path you want to rsync:”
  11. read rsyncpath
  12. echo “==========================input all completed========================”
  13. echo “==========================install rsync========================”
  14. yum -y install rsync
  15. useradd $username
  16. mkdir /etc/rsyncd
  17. cat >/etc/rsyncd/rsyncd.conf<<EOF
  18. # Minimal configuration file for rsync daemon
  19. # See rsync(1) and rsyncd.conf(5) man pages for help
  20. # This line is required by the /etc/init.d/rsyncd script
  21. pid file = /var/run/rsyncd.pid
  22. port = 873
  23. #address = $serverip
  24. #uid = nobody
  25. #gid = nobody
  26. uid = root
  27. gid = root
  28. use chroot = yes
  29. read only = yes
  30. #limit access to private LANs
  31. hosts allow=$allowip
  32. hosts deny=*
  33. max connections = 5
  34. motd file = /etc/rsyncd/rsyncd.motd
  35. #This will give you a separate log file
  36. #log file = /var/log/rsync.log
  37. #This will log every file transferred – up to 85,000+ per user, per sync
  38. #transfer logging = yes
  39. log format = %t %a %m %f %b
  40. syslog facility = local3
  41. timeout = 300
  42. [home]
  43. path = $rsyncpath
  44. list=yes
  45. ignore errors
  46. auth users = $username
  47. secrets file = /etc/rsyncd/rsyncd.secrets
  48. EOF
  49. echo “$username:$password” > /etc/rsyncd/rsyncd.secrets
  50. chmod 600 /etc/rsyncd/rsyncd.secrets
  51. cat >/etc/rsyncd/rsyncd.motd<<EOF
  52. +++++++++++++++++++++++++++
  53. + centos.bz  rsync  2011-2012 +
  54. +++++++++++++++++++++++++++
  55. EOF
  56. /usr/bin/rsync –daemon  –config=/etc/rsyncd/rsyncd.conf
  57. echo “/usr/bin/rsync –daemon  –config=/etc/rsyncd/rsyncd.conf” >>/etc/rc.d/rc.local
  58. ps -aux | grep rsync

2、赋予脚本权限

  1. chmod +x rsync.sh

3、执行脚本

  1. ./rsync.sh


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明linux 一键配置rsync服务器脚本
喜欢 (0)

您必须 登录 才能发表评论!

加载中……