apt update
apt install -y samba
iptables -I INPUT -p tcp --dport 445 -j ACCEPT
iptables -I INPUT -p udp --dport 137:138 -j ACCEPT
iptables -I INPUT -p tcp --dport 139 -j ACCEPT
nano /etc/samba/smb.conf
[global] workgroup = WORKGROUP security = user map to guest = bad user wins support = no dns proxy = no [public] path = /samba/public guest ok = yes force user = root browsable = yes writable = yes
[global] workgroup = WORKGROUP security = user map to guest = bad user wins support = no dns proxy = no [1c_backup] path = /mnt/1c/backup_1c guest ok = yes force user = nobody #force user = root browsable = yes writable = yes create mask = 0777 directory mask = 0777 hosts allow = 192.168.18.103 hosts deny = ALL
[private] path = /samba/private/ valid users = dmitry guest ok = no browsable = yes writable = yes
useradd dmitry -m -G users
smbpasswd -a dmitry
smbpasswd -e dmitry
smbpasswd dmitry
apt install cifs-utils -y
vi /etc/credentials
username=user_smb password=S#m#B#2017 domain=corp.unac
Доступ должен быть не только по сети но ки к файловой системе!
nano /etc/systemd/system/mnt-remote.mount
[Unit] Description=Mount SMB Share Requires=network-online.target After=network-online.target [Mount] What=//server/share Where=/mnt/remote Type=cifs Options=username=your_username,password=your_password,uid=1000,gid=1000,iocharset=utf8,file_mode=0777,dir_mode=0777 [Install] WantedBy=multi-user.target
Для монтирования SMB ресурса в режиме "только чтение" вы можете добавить параметр ro (read-only) в опции монтирования.
Options=username=your_username,password=your_password,ro
Запускаем службу
systemctl daemon-reload
systemctl start mnt-remote.mount
systemctl enable mnt-remote.mount
IP=192.168.18.103 SHARA_FROM=1c_backup # Shara MNT_POINT=/mnt/mount-point # Точка мониторвания SMB_V=2.0 # Версия smb источника
mount -t cifs //$IP/$SHARA_FROM $MNT_POINT -o credentials=/etc/credentials -o vers=$SMB_V -o ro
umount /mnt/mount-point
//192.168.18.33/FOR_lacal/ /mnt/1c/ cifs ro,vers=3.0,user=backup_users,password=hs47s 0 0
systemctl daemon-reload
mount -a