CentOS 一键配置rsync服务器脚本
发布时间:2011-12-20 22:15:41 作者:佚名 我要评论
保存下面的代码为一个文件,上传到服务器端,名称为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
复制代码
代码如下:#!/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
相关文章
- 虚拟机安装CentOS后没有网络了不能上网,该怎么设置网络呢?下面我们就来看看这个问题的解决办法,详细请看下文图文介绍2024-01-18
虚拟机怎么安装CentOS? 安装CentOS操作系统的保姆级图文教程
虚拟机想要安装CentOS操作系统,但是CentOS操作系统已经停止维护了,该怎么安装呢?详细请看下文图文教程2024-01-18Centos7.8怎么更新openssh? Centos升级openssh的技巧
Centos7.8怎么更新openssh?Centos7.8系统想要安装openssh,该怎么安装呢?下面我们就来看看Centos升级openssh的技巧2023-09-02Centos7.8怎么更新openssl? CentOS升级OpenSSL的技巧
Centos7.8怎么更新openssl?Centos7.8系统想要升级OpenSSL,该怎么升级呢?详细请看下文介绍2023-09-02- centos7没有图形化操作可能对很多人来说都不太习惯,下面我们来为centos7安装图形化界面,本文以安装 GNOME 图形化为例,需要的朋友可以参考下2023-06-29
- 今天小编在安装RHEL7的时候,一步留神没有安装图形化桌面,下面分享一下安装图形化桌面的过程,需要的朋友可以参考下2023-06-29
CentOS7各个版本镜像下载地址及版本说明(包括Everything版)
下载CentOS-7.0-1406的时候,有很多可选则的版本,对于普通用户来说,不知道选择哪个好,下面做一下简单介绍,需要的朋友可以参考下2023-06-01Centos 7怎么手动配置ip地址? Centos7配置IP地址的技巧
Centos 7怎么手动配置ip地址?Centos 7系统想要自己配置ip地址,该怎么操作呢?下面我们就来看看Centos7配置IP地址的技巧2023-05-17- 这篇文章主要介绍了Centos 7 压缩与解压缩命令小结,需要的朋友可以参考下2023-03-28
- 由于centos8 在2022年停止服务,后继版本为8-steam。在使用阿里云的 centos8 的 yum 时报错,这篇文章主要介绍了CentOS8使用阿里云yum源异常的解决方法,需要的朋友可以参考2022-04-19
最新评论