设置SMB服务专用账号,并创建共享目录
[root@localhost ~]# groupadd -r admins
[root@localhost ~]# useradd -s /sbin/nologin -G admins ptg1
[root@localhost ~]# smbpasswd -a ptg1
New SMB password:
[root@localhost ~]# smbpasswd -a ptg1
New SMB password:
Retype new SMB password:
Added user ptg1.
[root@localhost ~]# useradd -s /sbin/nologin ptg2
[root@localhost ~]# smbpasswd -a ptg2
New SMB password:
Retype new SMB password:
Added user ptg2.
[root@localhost ~]# mkdir /www
[root@localhost ~]# chgrp admins /www
[root@localhost ~]# chmod 2775 /www
安装服务并修改配置
[root@localhost ~]# yum install -y smaba
[root@localhost ~]# vim /etc/samba/smb.conf
[share]
path = /www
write list = @admins
客户端测试
[root@localhost ~]# yum -y install cifs-utils
[root@localhost ~]# mount -o username=ptg1 //192.168.103.74/share /www
[root@localhost ~]# ll /www
total 0
-rwxr-xr-x 1 root root 0 May 22 18:11 a.txt
服务器端查看效果
[root@localhost ~]# ll /www
total 0
-rwxr--r-- 1 ptg1 admins 0 May 22 18:11 a.txt
同步服务
1,搭建rsyncd服务器
2,在数据端将软件推送至rsyncd服务器上
搭建rsync服务器
[root@localhost ~]# yum install -y rsync
[root@localhost ~]# id rsync
uid=1000(rsync) gid=1000(rsync) groups=1000(rsync)
[root@localhost ~]# vim /etc/rsyncd.conf
uid = rsync
gid = rsync
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = false
auth users = rsync
secrets file = /etc/rsync.passwd
strict modes = no
log file = /var/log/rsyncd.log
[backup]
comment = welcome to oldboyedu backup!
path = /backup
[root@localhost ~]# cat /etc/rsync.passwd
rsync:ptg123
[root@localhost ~]# systemctl enable --now rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
#权限问题
[root@localhost ~]# ll /etc/rsync.passwd
-rw------- 1 root root 13 May 22 19:11 /etc/rsync.passwd
[root@localhost ~]# ll /backup -d
drwxrwxr-x 2 rsync rsync 46 May 22 19:19 /backup
[root@localhost ~]# ps aux | grep rsyncd
root 9807 0.0 0.0 112808 968 pts/0 R+ 19:22 0:00 grep --color=auto rsyncd
数据服务器端
[root@localhost ~]# wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz
--2021-05-22 18:20:14-- https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz
Resolving storage.googleapis.com (storage.googleapis.com)... 172.217.27.144, 172.217.24.16, 172.217.160.112, ...
Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.27.144|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 727290 (710K) [application/octet-stream]
Saving to: ‘sersync2.5.4_64bit_binary_stable_final.tar.gz’
100%[============================================================================>] 727,290 520KB/s in 1.4s
2021-05-22 18:20:17 (520 KB/s) - ‘sersync2.5.4_64bit_binary_stable_final.tar.gz’ saved [727290/727290]
[root@localhost ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@localhost ~]# cp -a GNU-Linux-x86 /usr/local/sersync
[root@localhost ~]# echo 'PATH=/usr/local/sersync:$PATH' >/etc/profile.d/sersync.sh
[root@localhost ~]# source /etc/profile.d/sersync.sh
[root@localhost www]# vim /usr/local/sersync/confxml.xml
<attrib start="ture"/>
<remote ip="192.168.103.75" name="backup"/>
<auth start="ture" users="rsync" passwordfile="/etc/rsync.pas"/>
[root@localhost ~]# cat /etc/rsync.pas
ptg123
[root@localhost ~]# ll /etc/rsync.pas
-rw------- 1 root root 7 May 22 19:10 /etc/rsync.pas
[root@localhost ~]# sersync2 -dro /usr/local/sersync/confxml.xml
防火墙,使用iptables -F是慎重
[root@localhost ~]# iptables -A INPUT -p tcp --dport 20:23 -j ACCEPT
[root@localhost ~]# iptables -A INPUT -p tcp --dport 139 -j ACCEPT
[root@localhost ~]# iptables -A INPUT -p tcp --dport 445 -j ACCEPT
[root@localhost ~]# iptables -P INPUT DROP