類別:原創 服務器 html
本文參考linux
samba配置文件詳解 http://yuanbin.blog.51cto.com/363003/115761/數據庫
samba配置安裝 http://www.cnblogs.com/haython/archive/2013/01/14/2860430.html第一:說明,軟件說明,和安裝的目的
架設基於linux下的samba服務器,設置linux共享目錄。 vim
第二:本例操做環境
所使用的系統環境爲 Centos 6.5 64位操做系統 bash
[root@tian ~]# uname -a
Linux tian.test.com 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@tian ~]# hostname
tian.test.com
[root@tian ~]# more /etc/redhat-release
CentOS release 6.5 (Final)
[root@tian ~]# 服務器
第三:samba 服務器配置
1. 安裝必須的軟件包
samba ide
samba-client 測試
[root@tian ~]# yum install samba samba-client –y 加密
2.修改主配置文件etc/samba/smb.conf
[root@tian ~]# cd /etc/samba/
[root@tian samba]# ls
lmhosts smb.conf smbusers
[root@tian samba]# vim smb.conf
[root@tian samba]# cat smb.conf | egrep -v "^;|^#|^$" | more 操作系統
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
hosts allow = 127. 192.168.12. 192.168.19. \\ 容許訪問的網段
# logs split per machine
log file = /var/log/samba/log.%m \\ log路徑
# max 50KB per log file, then rotate
max log size = 50 \\ log文件的最大容量爲50kB,0表明不限制。
security = user \\ 使用的認證方式,目前有四種認證方式,經常使用user方式爲 經過密碼文件來驗證
#passdb backend = tdbsam \\ 使用的認證後臺,目前有三種後臺,默認的是tdbsam方式,不過我習慣用smbpasswd方式,至於tdbsam方式 將做爲補充知識介紹一下
passdb backend = smbpasswd \\ 使用smbpasswd認證後臺
encrypt passwords = yes \\ 使用密碼加密方式 (默認設置)
smb passwd file = /etc/samba/smbpasswd \\ 密碼驗證文件(只有使用smbpasswd認證後臺,此選項纔有效,重啓smb時 會自動創建)
# the login script name depends on the machine name
# the login script name depends on the unix user used
# disables profiles support by specifing an empty path
load printers = yes
cups options = raw
#obtain list of printers automatically on SystemV
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[public]
comment = Public dir \\ 描述
path = /home/public \\ 共享目錄路徑(訪問用戶必須對這個目錄有相應權限)
valid users = public \\ 用來指定容許訪問該共享資源的用戶(invalid users 表明的是禁止)
public = no \\ 用來指定該共享是否容許guest帳戶訪問
writable = yes \\ 指定該共享路徑是否可寫
write list = @public \\ 用來指定能夠在該共享下寫入文件的用戶組
[root@tian samba]#
[root@tian samba]# ls
lmhosts smb.conf smbpasswd smbusers
3.增長samba用戶
[root@tian samba]# useradd -s /sbin/nologin public
[root@tian samba]# more /etc/passwd | grep public
public:x:503:503::/home/public:/sbin/nologin
[root@tian samba]#
[root@tian samba]# more smbpasswd
[root@tian samba]#
[root@tian samba]# smbpasswd -a public
New SMB password:
Retype new SMB password:
Added user public.
[root@tian samba]#
[root@tian samba]# more smbpasswd
public:503:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:32ED87BDB5FDC5E9CBA88547376818D4:[U ]:LCT-534B5229:
[root@tian samba]#
4.啓動相應的服務
[root@tian samba]# service smb restart
Shutting down SMB services: [FAILED]
Starting SMB services: [ OK ]
[root@tian samba]# service nmb restart
Shutting down NMB services: [FAILED]
Starting NMB services: [ OK ]
[root@tian samba]#
5.開機啓動相應的服務
[root@tian samba]# chkconfig smb on
[root@tian samba]# chkconfig nmb on
第四:測試
經過客戶端或是window 訪問samba 查看結果
[root@tian samba]# smbclient //127.0.0.1/public -U public%123456
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.9-168.el6_5]
smb: \> ls
. D 0 Mon Apr 14 11:34:15 2014
.. D 0 Mon Apr 14 10:39:38 2014
.gnome2 DH 0 Fri Nov 12 09:04:19 2010
fdfs D 0 Mon Apr 14 11:34:14 2014
.bash_profile H 176 Thu Jul 18 21:19:03 2013
.bashrc H 124 Thu Jul 18 21:19:03 2013
dsf D 0 Mon Apr 14 10:51:33 2014
.bash_logout H 18 Thu Jul 18 21:19:03 2013
.mozilla DH 0 Tue Mar 18 12:17:10 2014
47946 blocks of size 1048576. 45329 blocks available
smb: \> exit
[root@tian samba]#
[[root@tian ~]# smbstatus
Samba version 3.6.9-168.el6_5
PID Username Group Machine
-------------------------------------------------------------------
2649 public public tian (127.0.0.1)
Service pid machine Connected at
-------------------------------------------------------
public 2649 tian Mon Apr 14 11:38:42 2014
No locked files
[root@tian ~]#
第五:補充
1.使用tdbsam方式驗證密碼
[root@tian samba]# cat smb.conf | egrep -v "^;|^#|^$" | more
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
hosts allow = 127. 192.168.12. 192.168.19. \\ 容許訪問的網段
# logs split per machine
log file = /var/log/samba/log.%m \\ log路徑
# max 50KB per log file, then rotate
max log size = 50 \\ log文件的最大容量爲50kB,0表明不限制。
security = user \\ 使用的認證方式,目前有四種認證方式,經常使用user方式爲 經過密碼文件來驗證
passdb backend = tdbsam \\ 使用的認證後臺,目前有三種後臺,默認的是tdbsam方式,不過我習慣用smbpasswd方式
#passdb backend = smbpasswd \\ 使用smbpasswd認證後臺
#smb passwd file = /etc/samba/smbpasswd \\ 密碼驗證文件(只有使用smbpasswd認證後臺,此選項纔有效)
# the login script name depends on the machine name
# the login script name depends on the unix user used
# disables profiles support by specifing an empty path
load printers = yes
cups options = raw
#obtain list of printers automatically on SystemV
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[public]
comment = Public dir \\ 描述
path = /home/public \\ 共享目錄路徑(訪問用戶必須對這個目錄有相應權限)
valid users = public \\ 用來指定容許訪問該共享資源的用戶(invalid users 表明的是禁止)
public = no \\ 用來指定該共享是否容許guest帳戶訪問
writable = yes \\ 指定該共享路徑是否可寫
write list = @public \\ 用來指定能夠在該共享下寫入文件的用戶組
[root@tian samba]#
[root@tian samba]# pdbedit -L
[root@tian samba]# smbpasswd -a public
New SMB password:
Retype new SMB password:
Added user public.
[root@tian samba]# pdbedit -L
public:503:
[root@tian samba]# pdbedit -Lv
---------------
Unix username: public
NT username:
Account Flags: [U ]
User SID: S-1-5-21-719843599-709965791-3109227931-1004
Primary Group SID: S-1-5-21-719843599-709965791-3109227931-513
Full Name:
Home Directory: \\tian\public
HomeDir Drive:
Logon Script:
Profile Path: \\tian\public\profile
Domain: TIAN
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: Wed, 06 Feb 2036 23:06:39 CST
Kickoff time: Wed, 06 Feb 2036 23:06:39 CST
Password last set: Mon, 14 Apr 2014 11:43:10 CST
Password can change: Mon, 14 Apr 2014 11:43:10 CST
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
[root@tian samba]#
2.tdbsam相關的管理命令
pdbedit命令的參數不少,咱們列出幾個主要的。
pdbedit –a username:新建Samba帳戶。
pdbedit –x username:刪除Samba帳戶。
pdbedit –L:列出Samba用戶列表,讀取passdb.tdb數據庫文件。
pdbedit –Lv:列出Samba用戶列表的詳細信息。
pdbedit –c 「[D]」 –u username:暫停該Samba用戶的帳號。
pdbedit –c 「[]」 –u username:恢復該Samba用戶的帳號。
至此 全部配置完成