samba 文件共享
阿新 • • 發佈:2019-01-13
註意 程序 ear lin tab not 服務器 acl mkdir 部門分為兩塊:運維和測試(測試隸屬於運維管轄)
要求:
1.運維及測試成員只能對自己的目錄有讀寫權限,最終權在老大
2.建立一個集體共享目錄,所有人都有此目錄的權限
3.限制 ip ,避免賬號密碼的泄露
samba 文件共享
在說 samba 之前,先放一條 cmd 命令在上面,相信會用得到
打開cmd窗口執行命令
斷開所有連接
C:\Users>net use * /del /y
註意:
1. linux 中的用戶與 samba 中的用戶並沒有什麽關系,但 samba 中的用戶必須是 linux 系統中已有的用戶
2. windows 在連接 samba 時,同時只能連接一臺 samba 服務器中的一條線路,但可以同時連接多臺 samba 服務器,這個並不是 samba 的問題,而是 windows 本身的因素造成的
前情提要:
由於本部門為了保證自身數據不被泄露,決定不使用雲平臺的程序,要部署一臺備份共享服務器,實現數據安全及數據共享
要求:
1.運維及測試成員只能對自己的目錄有讀寫權限,最終權在老大
2.建立一個集體共享目錄,所有人都有此目錄的權限
3.限制 ip ,避免賬號密碼的泄露
環境:CentOS Linux release 7.5.1804 (Core)
一:安裝 server 端
# yum search samba #查找smb文件共享服務所需軟件 # yum install samba-client.x86_64 samba-common.x86_64 samba.x86_64 -y (samba-swat.x86_64 可配置網頁版) # systemctl start smb #啟動 smb # systemctl enable smb #開機自啟 # systemctl stop firewalld #關閉防火墻 # systemctl disable firewalld #防火墻開機禁啟 # netstat -antlupe | grep smb #查看端口
不關閉防火墻時:
iptables -I RH-Firewall-1-INPUT 5 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT iptables -I RH-Firewall-1-INPUT 5 -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT iptables -I RH-Firewall-1-INPUT 5 -p udp -m udp --dport 137 -j ACCEPT iptables -I RH-Firewall-1-INPUT 5 -p udp -m udp --dport 138-j ACCEPT iptables-save service iptables restart
二:創建每個部門的用戶組
# groupadd ceshi
# groupadd yunwei
三:先創建系統用戶,並加入自己的用戶組
# useradd -g ceshi -s /sbin/nologin cs
# useradd -g ceshi -s /sbin/nologin cs2
# useradd -g yunwei -s /sbin/nologin yw
# useradd -g yunwei -s /sbin/nologin yw2
# useradd -g yunwei -s /sbin/nologin admin
四:添加用戶:
# id ysg #查看是否有 ysg 系統用戶。
# smbpasswd -a ysg #添加 ysg 系統用戶到 smb 服務用戶
# pdbedit -L #查看 smb 服務允許用戶
# pdbedit -x ysg #刪除 ysg 用戶
系統中沒有 ysg 用戶時:
# id ysg #無 ysg 用戶
id: ysg: no such user
# smbpasswd -a ysg
New SMB password:
Retype new SMB password:
Failed to add entry for user ysg. #添加不成功
# useradd ysg #創建westos用戶
# smbpasswd -a ysg
New SMB password:
Retype new SMB password:
Added user ysg. #此時添加成功
六:創建目錄
# mkdir -p /etc/samba/ ceshi yunwei
# mkdir -p /etc/samba/ ceshi ceshi
# mkdir -p /etc/samba/ ceshi share
七:更改配置文件,實現權限的分配,限制 ip 登錄白名單
# hosts allow = the hosts allowed to connect. This option can also be used on a
# per-share basis.
#
# hosts deny = the hosts not allowed to connect. This option can also be used on
# a per-share basis.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
hosts allow = 192.168.80.110 192.168.80.111
#[homes]
# comment = Home Directories
# valid users = %S, %D%w%S
# browseable = No
# read only = No
# inherit acls = Yes
[共享目錄]
comment = this is share
path = /etc/samba/share
writable = yes
admin users = @yunwei,@ceshi
valid users = @yunwei,@ceshi
create mask = 777
directory mask = 777
[運維]
comment = this is yunwei
path = /etc/samba/yunwei
writable = yes
admin users = admin,@yunwei
valid users = admin,@yunwei
create mask = 664
directory mask = 775
[測試]
comment = this is ceshi
path = /etc/samba/ceshi
writable = yes
admin users = admin,@ceshi
valid users = admin,@ceshi
create mask = 664
directory mask = 775
實現上面的 下面就不必配置了
配置 selinux:
# getsebool -a | grep smb
smbd_anon_write --> off
# getsebool -a | grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_sandbox_use_samba --> off
virt_use_samba --> off
# setsebool -P samba_enable_home_dirs on
# setsebool -Psamba_export_all_rw on
samba 文件共享