rsync+stunnel部署安装

环境:服务端centos7(langly) 客户端ubuntu(frohike)

一、安装openssl 制作ssl证书

可在任意电脑主机安装配置
1、yum install openssl
默认需要的东西安装在/etc/pki/**
2、openssl.conf 配置(一般不用)
一下几项比较重要

[CA_default]
dir =/etc/pki/CA
certs = $dir/certs
crl_dir = $dir/crl
database = $dir/index.txt
new_certs_dir = $dir/newcerts
certificate = $dir/cacert.pem
serial = $dir/serial
crlunmber = $dir/crlnumber
crl = $dir/crl.pem
private_key = $dir/private/cakey.pem

3、生成配置相关文件

cd /etc/pki/tls/misc 
./CA -newca 

执行是会有交互
第一个提示 回车
passphrase  自己定义密码(如:Don't worry, this is my 1st CA and it's much more secure than a password like 52334XCq24sdf122, Dude!)
Organizational Unit Name   如:证书颁发机构
Common Name   你的ip
A challenge password   不需要填写

4、生成CA签证:
以下是制作服务端(longly)的签证

# 生成自己的秘钥:
openssl genrsa -out langly_ssl.key 2048

#对秘钥进行加密:
openssl rsa -in langly_ssl.key -des3 -out langly_encrypted.key

#生成证书请求
openssl req -new -key langly_ssl.key -out langly_ssl.csr

# 生成X509自签名
openssl x509 -req -in langly_ssl.csr -signkey langly_ssl.key -out langly_ssl.crt

制作客户端(frohike)与服务端相似只需要把文件名字换成frohike_stunnel_**.pem 
common name 修改为客户端的名字(frohike)
Organizational Unit Name 修改为stunnel客户端即可

二、安装配置rsync

需要服务器和客户端都安装
服务器端:
1、安装:
yum install rsync
2、配置:
修改rsync配置文件文件在/etc/rsyncd.conf

syslog faciity = local5
use chroot = yes
uid = root
gid = root
max connections = 10
timeout = 600
read only = yes

[frohike]
        path = /backup/frohike 
        comment = Frohike Backups
        auth users = root #系统中已有的用户名
        hosts allow = 127.0.0.1
        secrets file =/etc/rsyncd.secrets
        read only = no
        ignore nonreadable = yes
        refuse options = checksum
        dont compress = *
        
# 终端执行
echo "root:1234" > /etc/rsyncd.secrets #用户名是系统中已有的用户名,密码可以自己设置可以不是系统中用户名的密码。
chmod 600 /etc/rsyncd.secrets
rsync --daemon

/backup/frohike 已有文档 需要同步的文件
hosts allow 为127.0.0.1只允许自己主机连接 因为本机的stunnel接收的数据传给本机的rsync

客户端安装(客户端无需配置)
1、sudo apt-get install rsync

三、stunnel安装与配置

需要客户端服务端都安装和配置

服务端:
1、安装
yum install stunnel

2、配置

  • 在/etc/servies下添加端口服务信息(可不做)
    ssyncd 273/tcp # secure rsync over stunnel

  • 在/etc/hosts.allow下添加以下行(可不做)
    ssyncd : xx.xx.xx.xx # xxx 为服务端ip

  • 配置stunnel.conf文件(/etc/stunnel/stunnel.conf)

cp langly_ssl.key /etc/stunnel/
cp langly_ssl.crt /etc/stunnel/

key = /etc/stunnel/langly_ssl.key
cert = /etc/stunnel/langly_ssl.crt

client = no
pid = /var/run/stunnel.pid 

#debug = 7 
#foreground = yes 

[ssync] 
accept = 273
connect = 873
  • 终端启动 
    stunnel # 执行后无返回为成功
  • 查看服务是否开启:
    netstat -pan | grep stunnel

客户端:
1、安装 sudo apt-get install stunnel

2、配置

  • 在/etc/servies下添加端口服务信息(可不做)
    ssync 273/tcp # rsync over stunnel
  • 在/etc/hosts.allow下添加一下行 使本地连接ssync端口上传递(可不做)
    ssync : LOCAL
  • 配置stunnel.conf文件(/etc/stunnel/stunnel.conf)
key = /etc/stunnel/frohike_ssl.key
cert = /etc/stunnel/frohike_ssl.crt 

client = yes 
pid = /var/run/stunnel.pid 

#debug = 7 
#foreground = yes 

[ssync] 
accept = 873 
connect = domain.of.langly.com:273 # domain.of.langly.com 换成服务端ip
  • 终端启动 
    stunnel # 执行后无返回为成功
  • 查看服务是否开启:
    netstat -pan | grep stunnel

四、测试

客户端执行:

rsync -vv -a -R --numeric-ids /etc/stunnel/stunnel.conf localhost::frohike

#返回
opening tcp connection to localhost port 873
sending daemon args: --server -vvlogDtprRe.iLsfx --numeric-ids . frohike/  (5 args)
sending incremental file list
Setting --timeout=600 to match server
/etc/
/etc/stunnel/
/etc/stunnel/stunnel.conf
total: matches=0  hash_hits=0  false_alarms=0 data=132
sent 301 bytes  received 55 bytes  237.33 bytes/sec
total size is 132  speedup is 0.37

rsync -avz root@127.0.0.1::frohike /test #同步数据在本/test文件夹下

#返回
Password: 
receiving incremental file list
created directory /frohikes
./
tests
testss
sent 69 bytes  received 217 bytes  63.56 bytes/sec
total size is 31  speedup is 0.11
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
根据提供的引用内容,可以得知本套方案采用了NFS+Rsync+Keepalived的高可用架构方案,其中利用NFS服务提供一个共享目录,供客户端挂载到自己的文件系统中。而Rsync则是一种常用的文件同步工具,可以将本地或远程的文件同步到另一台服务器上。统信UOS是一款国产操作系统,支持Rsync工具。 因此,可以通过在统信UOS上安装Rsync工具,实现文件的同步和备份。具体步骤如下: 1. 安装Rsync工具 可以通过以下命令在统信UOS上安装Rsync工具: ```shell sudo apt-get install rsync ``` 2. 配置Rsync服务 可以通过编辑Rsync配置文件/etc/rsyncd.conf来配置Rsync服务。例如,可以添加以下内容: ```shell uid = root gid = root use chroot = no max connections = 10 pid file = /var/run/rsyncd.pid exclude = lost+found/ transfer logging = yes log format = %t: %a: %m: %f: %b log file = /var/log/rsyncd.log [backup] path = /backup comment = Backup Folder read only = no list = yes ``` 其中,[backup]表示共享的目录名,path表示共享的目录路径,comment表示注释,read only表示是否只读,list表示是否允许列出目录内容。 3. 启动Rsync服务 可以通过以下命令启动Rsync服务: ```shell sudo rsync --daemon --config=/etc/rsyncd.conf ``` 4. 进行文件同步 可以通过以下命令进行文件同步: ```shell rsync -avz /local/path user@remote:/remote/path ``` 其中,/local/path表示本地路径,user@remote表示远程服务器的用户名和IP地址,/remote/path表示远程路径。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值