這篇文章主要講解了“怎么實(shí)現(xiàn)Samba文件共享服務(wù)”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么實(shí)現(xiàn)Samba文件共享服務(wù)”吧!
成都創(chuàng)新互聯(lián)公司主要為客戶提供服務(wù)項(xiàng)目涵蓋了網(wǎng)頁視覺設(shè)計(jì)、VI標(biāo)志設(shè)計(jì)、成都全網(wǎng)營銷、網(wǎng)站程序開發(fā)、HTML5響應(yīng)式成都網(wǎng)站建設(shè)、手機(jī)網(wǎng)站制作、微商城、網(wǎng)站托管及網(wǎng)站維護(hù)、WEB系統(tǒng)開發(fā)、域名注冊、國內(nèi)外服務(wù)器租用、視頻、平面設(shè)計(jì)、SEO優(yōu)化排名。設(shè)計(jì)、前端、后端三個(gè)建站步驟的完善服務(wù)體系。一人跟蹤測試的建站服務(wù)標(biāo)準(zhǔn)。已經(jīng)為活動(dòng)板房行業(yè)客戶提供了網(wǎng)站推廣服務(wù)。
配置用戶認(rèn)證共享
服務(wù)端操作:
1.關(guān)閉防火墻,關(guān)閉selunix
[root@hejie ~]# setenforce 0 [root@hejie ~]# systemctl stop firewalld
2.安裝軟件包
[root@hejie ~]# yum install samba-* -y
3.啟動(dòng)smb并設(shè)置開機(jī)自啟
[root@hejie ~]# systemctl start smb [root@hejie ~]# systemctl enable smb Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
關(guān)于Samba的配置文件
[root@hejie ~]# grep -Ev '^#|^$' /etc/samba/smb.conf [global] //全局參數(shù) workgroup = SAMBA //工作組名稱 非常重要 security = user //安全驗(yàn)證方式,總共四種 //share:無需驗(yàn)證身份,簡單方便,安全性差 //user:需要驗(yàn)證用戶密碼才可以訪問,安全性高 //server:需要通過三方服務(wù)器驗(yàn)證賬號(hào)密碼,(集中管理賬戶) //domain:使用域控制器進(jìn)行身份驗(yàn)證 passdb backend = tdbsam //定義用戶后臺(tái)的類型,共有三種 //smbpasswd:為系統(tǒng)用戶設(shè)置Samba服務(wù)程序的密碼 //tdbsam:創(chuàng)建數(shù)據(jù)庫文件并使用pdbedit命令建立Samba服務(wù)程序的用戶 //ldapsam:基于LDAP服務(wù)進(jìn)行賬戶驗(yàn)證 printing = cups //設(shè)置Samba共享打印機(jī)的類型 printcap name = cups //設(shè)置共享打印機(jī)的配置文件 load printers = yes //設(shè)置在Samba服務(wù)啟動(dòng)時(shí)是否共享打印機(jī)設(shè)備 cups options = raw //打印機(jī)的選項(xiàng) [homes] //共享參數(shù) comment = Home Directories //描述信息 valid users = %S, %D%w%S //允許訪問該共享的用戶 browseable = No //指定共享信息是否可見 read only = No inherit acls = Yes [printers] comment = All Printers 任意字符串 path = /var/tmp 共享目錄路徑 printable = Yes create mask = 0600 browseable = No 指定該共享是否可以瀏覽 [print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = root 允許寫入該共享的用戶 create mask = 0664 directory mask = 0775
4.添加用戶"zhengran",不創(chuàng)建家目錄,并設(shè)置密碼。
[root@hejie ~]# useradd -M zhengran [root@hejie ~]# smbpasswd -a zhengran New SMB password: Retype new SMB password: Added user zhengran.
假設(shè)這里映射"zhengran"用戶為share用戶,那么就要在/etc/samba/smbusers文件中添加如下內(nèi)容:
[root@hejie ~]# echo 'zhengran = share' > /etc/samba/smbusers
5.在全局配置中添加如下內(nèi)容:
[root@hejie ~]# vim /etc/samba/smb.conf [global] workgroup = SAMBA security = user username map = /etc/samba/smbusers //添加此行內(nèi)容 passdb backend = tdbsam
6.創(chuàng)建一個(gè)共享目錄“zhengran”,并更改其屬主屬組為用戶“zhengran”
[root@hejie ~]# mkdir /opt/zhengran [root@hejie ~]# chown -R zhengran.zhengran /opt/zhengran/ [root@hejie ~]# ll /opt/ total 0 drwxr-xr-x. 2 zhengran zhengran 6 Aug 7 17:22 zhengran
7.配置共享
[root@hejie ~]# cat >> /etc/samba/smb.conf <[zhengran] //共享名 > comment = zhengranwoaini //注釋信息 > path = /opt/zhengran //共享目錄路徑 > browseable = yes //指定該共享是否可以瀏覽 > guest ok = yes //指定該共享是否允許guset賬戶訪問 > writable = yes //指定目錄是否可寫 > write list = share //允許寫入該共享的用戶,組要用@表示,例如: write list = root,@root > public = yes //是否允許匿名訪問 > EOF
8.用testparm檢查配置文件是否有語法錯(cuò)誤,可顯示最終生效的配置
[root@hejie ~]# testparm Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Processing section "[homes]" Processing section "[printers]" Processing section "[print$]" Processing section "[zhengran]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions # Global parameters [global] workgroup = SAMBA printcap name = cups security = USER username map = /etc/samba/smbusers idmap config * : backend = tdb cups options = raw [homes] comment = Home Directories browseable = No inherit acls = Yes read only = No valid users = %S %D%w%S [printers] comment = All Printers path = /var/tmp browseable = No printable = Yes create mask = 0600 [print$] comment = Printer Drivers path = /var/lib/samba/drivers create mask = 0664 directory mask = 0775 write list = root [zhengran] comment = zhengranwoaini path = /opt/zhengran guest ok = Yes read only = No write list = share
9.重啟smb
[root@hejie ~]# systemctl restart smb
客戶端上操作:
1.安裝工具包
[root@hyj ~]# yum install samba-client cifs-utils -y
在客戶機(jī)查看samba服務(wù)端有哪些共享資源
[root@hyj ~]# smbclient -L 192.168.56.11 -U share Enter SAMBA\share's password: Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers zhengran Disk zhengranwoaini IPC$ IPC IPC Service (Samba 4.6.2) Reconnecting with SMB1 for workgroup listing. Server Comment --------- ------- Workgroup Master --------- -------
3.創(chuàng)建目錄,并將samba服務(wù)器的共享資源zhengran掛載到客戶機(jī)本地
[root@hyj ~]# mkdir /opt/ran [root@hyj ~]# mount -t cifs //192.168.56.11/zhengran /opt/ran -o username=share,password=123 [root@hyj ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/CentOS-root 17G 1016M 16G 6% / devtmpfs 982M 0 982M 0% /dev tmpfs 993M 0 993M 0% /dev/shm tmpfs 993M 8.5M 984M 1% /run tmpfs 993M 0 993M 0% /sys/fs/cgroup /dev/sda1 1014M 125M 890M 13% /boot tmpfs 199M 0 199M 0% /run/user/0 //192.168.56.11/zhengran 47G 5.4G 42G 12% /opt/ran
4.在客戶機(jī)掛載點(diǎn)創(chuàng)建新文件
[root@hyj ~]# cd /opt/ran/ [root@hyj ran]# touch 1 2 3 [root@hyj ran]# ls 1 2 3
5.在服務(wù)器上驗(yàn)證
[root@hejie ~]# cd /opt/zhengran/ [root@hejie zhengran]# ls 1 2 3
配置匿名共享
服務(wù)端
1.修改配置文件
[root@hejie ~]# vim /etc/samba/smb.conf [global] workgroup = SAMBA security = user map to guest = Bad User //添加此行
2.創(chuàng)建共享目錄
[root@hejie ~]# mkdir /opt/ranran [root@hejie ~]# chmod 777 /opt/ranran/ [root@hejie ~]# ll /opt/ranran/ -d drwxrwxrwx. 2 root root 6 Aug 7 19:24 /opt/ranran/
3.配置共享
[root@hejie ~]# cat >> /etc/samba/smb.conf <[ran] > comment = ranranwoaini > path = /opt/ranran > browseable = yes > writable = yes > guest ok = yes > public = yes > EOF
4.重啟服務(wù)
[root@hejie ~]# systemctl restart smb
5.在客戶機(jī)上查看服務(wù)器端有哪些共享資源
[root@hyj ~]# smbclient -L 192.168.56.11 -U 'Bad User' Enter SAMBA\Bad User's password: // 這里直接敲回車,不用輸入密碼 Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers zhengran Disk zhengranwoaini ran Disk ranranwoaini IPC$ IPC IPC Service (Samba 4.6.2) Reconnecting with SMB1 for workgroup listing. Server Comment --------- ------- Workgroup Master --------- -------
6.將samba服務(wù)器的共享資源ran掛在到客戶機(jī)上
[root@hyj ~]# mount -t cifs //192.168.56.11/ran /opt/ran -o username='Bad User' Password for Bad User@//192.168.56.11/ran: [root@hyj ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 17G 1016M 16G 6% / devtmpfs 982M 0 982M 0% /dev tmpfs 993M 0 993M 0% /dev/shm tmpfs 993M 8.5M 984M 1% /run tmpfs 993M 0 993M 0% /sys/fs/cgroup /dev/sda1 1014M 125M 890M 13% /boot tmpfs 199M 0 199M 0% /run/user/0 //192.168.56.11/ran 47G 5.4G 42G 12% /opt/ran
7.在客戶機(jī)上進(jìn)入共享目錄創(chuàng)建新文件
[root@hyj ~]# cd /opt/ran/ [root@hyj ran]# ls [root@hyj ran]# touch a b c [root@hyj ran]# ls a b c
8.在服務(wù)端驗(yàn)證
[root@hejie ~]# cd /opt/ranran/ [root@hejie ranran]# ls a b c
感謝各位的閱讀,以上就是“怎么實(shí)現(xiàn)Samba文件共享服務(wù)”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對怎么實(shí)現(xiàn)Samba文件共享服務(wù)這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
當(dāng)前名稱:怎么實(shí)現(xiàn)Samba文件共享服務(wù)
網(wǎng)頁鏈接:http://jinyejixie.com/article0/pppcoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、虛擬主機(jī)、網(wǎng)站營銷、靜態(tài)網(wǎng)站、Google、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)