服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - CentOS 一键配置rsync服务器脚本

CentOS 一键配置rsync服务器脚本

2019-10-08 16:07服务器之家 Centos

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

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

复制代码

代码如下:


#!/bin/bash 
#rsync Written by zhumaohai 
#For more information please visit http://www.centos.bz 
echo "Please input the rsync username:" 
read username 
echo "Please input the rsync username password:" 
read password 
echo "Please input the server ip address:" 
read serverip 
echo "Please input the allow ip address:" 
read allowip 
echo "Please input the path you want to rsync:" 
read rsyncpath 
echo "==========================input all completed========================" 
echo "==========================install rsync========================" 
yum -y install rsync 
useradd $username 
mkdir /etc/rsyncd 
cat >/etc/rsyncd/rsyncd.conf<<eof 
# Minimal configuration file for rsync daemon 
# See rsync(1) and rsyncd.conf(5) man pages for help 
# This line is required by the /etc/init.d/rsyncd script 
pid file = /var/run/rsyncd.pid 
port = 873 
address = $serverip 
#uid = nobody 
#gid = nobody 
uid = root 
gid = root 
use chroot = yes 
read only = yes 

#limit access to private LANs 
hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0 $allowip 
hosts deny=* 
max connections = 5 
motd file = /etc/rsyncd/rsyncd.motd 
#This will give you a separate log file 
#log file = /var/log/rsync.log 
#This will log every file transferred - up to 85,000+ per user, per sync 
#transfer logging = yes 
log format = %t %a %m %f %b 
syslog facility = local3 
timeout = 300 
[$username home] 
path = $rsyncpath 
list=yes 
ignore errors 
auth users = $username 
secrets file = /etc/rsyncd/rsyncd.secrets 
eof 
echo "$username:$password" > /etc/rsyncd/rsyncd.secrets 
chmod 600 /etc/rsyncd/rsyncd.secrets 
cat >/etc/rsyncd/rsyncd.motd<<eof 
+++++++++++++++++++++++++++ 
+ centos.bz rsync 2011-2012 + 
+++++++++++++++++++++++++++ 
eof 
/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf 
ps -aux | grep rsync 


2、赋予脚本权限 

复制代码

代码如下:


chmod +x rsync.sh 


3、执行脚本 

复制代码

代码如下:


./rsync.sh 


4、客户端同样需要安装rsync

延伸 · 阅读

精彩推荐
  • CentosCentOS上SVN服务器端程序的安装与使用教程

    CentOS上SVN服务器端程序的安装与使用教程

    SVN是一款高人气的软件项目版本控制系统,由于其在Windows的客户端的简易操作,在Git的浪潮中仍然保有很多的用户数量,这里我们就来看一下CentOS上SVN服务器端...

    cnblogs3902019-07-16
  • CentosCentOS6.2网卡设置

    CentOS6.2网卡设置

    如果你想让服务器可以更新、让网友访问你的LINUX服务器,那一定要设置LINUX网上给网卡绑定一个IP,下面我们就介绍CentOS6.2网卡设置IP的方法。...

    CentOS教程网10092021-10-03
  • Centos在CentOS系统上安装Docker的教程

    在CentOS系统上安装Docker的教程

    这篇文章主要介绍了在CentOS系统上安装Docker的教程,Docker是当下人气最为火热的容器类虚拟软件,需要的朋友可以参考下 ...

    开源中文社区3952019-09-17
  • Centoscentos 7中添加一个新用户并授权的步骤详解

    centos 7中添加一个新用户并授权的步骤详解

    这篇文章主要给大家介绍了关于在centos 7中添加一个新用户并授权的步骤,文中将实现的步骤介绍的非常详细,通过文中介绍的步骤可以轻松的创建一个新...

    Ryan.Miao9832022-02-12
  • CentosCentOS7 阿里云的yum源使用详解

    CentOS7 阿里云的yum源使用详解

    这篇文章主要介绍了CentOS7 阿里云的yum源使用详解的相关资料,这里对备份yum源,添加EPEL源,和缓存清理,进行了介绍,需要的朋友可以参考下...

    天王9312020-12-28
  • Centos使用Xshell连接Centos 6.6服务器操作图文教程

    使用Xshell连接Centos 6.6服务器操作图文教程

    这篇文章主要介绍了使用Xshell连接Centos 6.6服务器操作图文教程,本文用详细的操作步骤讲解了如何使用Xshell连接Centos服务器,需要的朋友可以参考下 ...

    脚本之家4032019-09-18
  • CentosCentOS系统下软件包的制作方法和过程详解

    CentOS系统下软件包的制作方法和过程详解

    今天小编将为大家带来的是CentOS系统下软件包的制作方法和过程详解;希望对大家会有帮助,有需要的朋友一起去看看吧...

    CentOS之家4802019-05-30
  • CentosCentOS 最新版本git的安装教程

    CentOS 最新版本git的安装教程

    本文主要给大家介绍了CentOS 最新版本git的安装教程,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧...

    CentOS教程网9252021-11-29