21 Samba配置詳解
1、SMB介紹
Samba可以實現Linux和Windows的檔案共享
SMB(Service Message Block)涉及的埠
smb:tcp 139 445
nmbd udp 137 138
samba使用者是系統使用者但密碼是獨立的,非/etc/shadow中的密碼,使用smbpasswd設定訪問smb的密碼。
sambclient -L Server -U username檢查伺服器上的共享
smbclient //Server/Shared -U username以互動式模式連入伺服器的某共享
smb配置檔案/etc/samba/smb.conf常用選項
[global]
interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 指定監聽的IP、埠
hosts allow = 127. 192.168.12. 192.168.13.指定可以訪問SMB的IP
[public]
comment = Public Stuff
path = /home/samba 指定共享的目錄
write list = +staff 指定只有staff組中的使用者有寫許可權
create mask = 0644 修改檔案許可權
testparm測試配置檔案語法錯誤,並顯示最終生效的配置
linux掛載cifs檔案系統
mount -t cifs //Server/Shared /path/to/mount_point -o username=smbuser
2、SMB安裝配置
共享名為myshared,僅mygroup組中的使用者具有執行許可權,所有檔案不具有執行許可權,不可刪除他人上傳的檔案
yum -y install samba samba-client
[[email protected] ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[myshared]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
client signing = required
idmap config * : backend = tdb
cups options = raw
[myshared]
comment = myshared
path = /myshared
write list = +mygroup
create mask = 0644
[[email protected] ~]#
groupadd mygroup
useradd -m userrw
useradd -m userro
usermod -a -G mygroup userrw
smbpasswd -a userrw
smbpasswd -a userro
mkdir /myshared
chown root:mygroup /myshared
chmod +t /myshared
chmod g+w /myshared
service smb start
service nmb start
chkconfig smb on
chkconfig nmb on