您好,登錄后才能下訂單哦!
####samba#########
1samba作用
提供cifs協(xié)議實(shí)現(xiàn)共享文件
2安裝
yum install samba samba-common samba-client -y
systemctl start smb nmb
systemctl enable smb nmb
systemctl stop firewalld.service
3添加smb用戶
smb用戶必須是本地用戶
smbpasswd -a student
New SMB password: #輸入smb當(dāng)前用戶密碼
Retype new SMB password:#確認(rèn)密碼
Added user student.
pdbedit -L#查看smb用戶信息
student:1000:Student User
pdbedit -x student#刪除smb用戶
setsebool -P samba_enable_home_dirs on ##在selinux中設(shè)定smb用戶可以訪問自己的家目錄
4共享目錄的基本設(shè)定
117
mkdir /smbshare
touch /smbshare/123
vim /etc/samba/smb.conf
321 [westos] ##共享名稱
322 comment = local directory ##對(duì)共享目錄的描述
323 path = /smbshare ##共享目錄的絕對(duì)路徑
當(dāng)共享目錄為用戶自建目錄時(shí)
semanage fcontext -a -t samba_share_t '/smbshare(/.*)?'
restorecon -Rvvf /smbshare/
systemctl restart smb.service
測(cè)試
17
[root@dns-server 桌面]# smbclient //172.25.254.117/westos -U student
Enter student's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
. D 0 Sat Jun 3 14:39:20 2017
.. D 0 Sat Jun 3 14:39:12 2017
123 N 0 Sat Jun 3 14:39:20 2017
10473900 blocks of size 1024. 7316272 blocks available
smb: \> SMBecho failed (NT_STATUS_CONNECTION_DISCONNECTED). The connection is disconnected now
當(dāng)共享目錄為系統(tǒng)建立目錄
setsebool -P samba_export_all_ro on#只讀共享
setsebool -P samba_export_all_rw on#讀寫共享
systemctl restart smb.service
測(cè)試
17
[root@dns-server 桌面]# smbclient //172.25.254.117/westos -U student
Enter student's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
. D 0 Sat Jun 3 13:54:54 2017
.. D 0 Sat Jun 3 14:39:12 2017
fstab N 313 Wed May 7 09:22:57 2014
crypttab N 0 Wed May 7 09:22:57 2014
mtab R 0 Sat Jun 3 14:47:19 2017
pki D 0 Wed May 7 09:27:13 2014
rpm D 0 Fri Jul 11 06:36:36 2014
yum D 0 Wed May 7 09:24:49 2014
issue N 23 Tue Apr 1 21:28:10 2014
binfmt.d D 0 Wed Apr 2 21:30:23 2014
issue.net N 22 Tue Apr 1 21:28:10 2014
modules-load.d D 0 Wed Apr 2 21:30:23 2014
os-release N 493 Tue Apr 1 21:28:10 2014
fonts D 0 Fri Jul 11 06:22:37 2014
redhat-release N 52 Tue Apr 1 21:28:10 2014
DIR_COLORS.256color N 5725 Sat Jan 25 03:23:50 2014
。。。。。。。
5samba的配置參數(shù)
#匿名用戶訪問
vim /etc/samba/smb.conf
125 map to guest = bad user
324guest ok = yes
測(cè)試
17
[root@dns-server 桌面]# smbclient //172.25.254.117/westos
Enter kiosk's password: ###無密碼
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
. D 0 Sat Jun 3 14:39:20 2017
.. D 0 Sat Jun 3 14:39:12 2017
123 N 0 Sat Jun 3 14:39:20 2017
10473900 blocks of size 1024. 7305320 blocks available
#訪問控制
hosts allow = ##僅允許
hosts deny = ##僅拒絕
valid users = #當(dāng)前共享的有效用戶
valid users = westos#當(dāng)前共享的有效用戶為westos
valid users = @westos#當(dāng)前共享的有效用戶為westos組
valid users = +westos#當(dāng)前共享的有效用戶為westos組
測(cè)試
117
vim /etc/samba/smb.conf
325 hosts allow = 172.25.254.17
17
[root@dns-server 桌面]# smbclient //172.25.254.117/westos
Enter kiosk's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
. D 0 Sat Jun 3 14:39:20 2017
.. D 0 Sat Jun 3 14:39:12 2017
123 N 0 Sat Jun 3 14:39:20 2017
10473900 blocks of size 1024. 7305276 blocks available
217
[root@localhost ~]# smbclient //172.25.254.117/westos
Enter root's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
tree connect failed: NT_STATUS_ACCESS_DENIED
測(cè)試
117
vim /etc/samba/smb.conf
324 valid users = westos
17
[root@dns-server 桌面]# useradd westos -s /sbin/nologin
[root@dns-server 桌面]# smbpasswd -a westos
New SMB password:
Retype new SMB password:
Added user westos.
[root@dns-server 桌面]# smbclient //172.25.254.117/westos -U westos
Enter westos's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \>
##讀寫控制
所有用戶均可寫
chmod o+w /smbshare ##修改共享目錄權(quán)限
setsebool -P samba_export_all_rw on
vim /etc/samba/smb.conf
324 writable = yes
systemctl restart smb.service
測(cè)試
17
[root@dns-server 桌面]# mount -o username=westos,password=redhat //172.25.254.117/westos /mnt/
[root@dns-server 桌面]# cd /mnt/
[root@dns-server mnt]# ls
123
[root@dns-server mnt]# touch file3
[root@dns-server mnt]# ls
123 file3
設(shè)定指定用戶可寫
write list = student #可寫用戶
write list = +student#可寫用戶組
write list = @stident
admin users = westos#共享的超級(jí)用戶指定
測(cè)試
117
vim /etc/samba/smb.conf
324 writable = no
325 write list = student
217
smbpasswd -a student
useradd westos
usermod -G westos student
mount -o username=student,password=123 //172.25.254.117/westos /mnt/
[root@localhost mnt]# ls
123 1234fref file3
[root@localhost mnt]# touch file5
[root@localhost mnt]# ls
123 1234fref file3 file5
測(cè)試
117
vim /etc/samba/smb.conf
324 writable = yes
325 admin users = westos
217
[root@localhost ~]# mount -o username=westos,password=redhat //172.25.254.117/westos /mnt/
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
123 1234fref file3 file5
[root@localhost mnt]# touch file6
[root@localhost mnt]# ls -l file6
-rw-r--r--. 1 root westos 0 6月 3 04:36 file6
6smb多用戶掛載
在client(客戶端)上
vim /root/haha
username=student
password=123 ##密碼為smb密碼
chmod 600 /root/haha
yum install cifs-utils.x86_64 -y
mount -o credentials=/root/haha,multiuser,sec=ntlmssp //172.25.254.117/westos /mnt/
#credentials=/root/haha 指定掛載時(shí)所用到的用戶文件
#multiuser 支持多用戶認(rèn)證
#sec=ntlmssp認(rèn)證方式為標(biāo)準(zhǔn)smb認(rèn)證方式
[root@localhost ~]# su - westos
[westos@localhost ~]$ ls /mnt
ls: cannot access /mnt: Permission denied #因?yàn)闆]有作smb的認(rèn)證所以無法訪問smb的共享
[westos@localhost ~]$ cifscreds add -u westos 172.25.254.117
Password: ##smb用戶westos的密碼
[westos@localhost ~]$ ls /mnt
123 1234fref file3 file5 file6
[westos@localhost ~]$
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。