Recently, I updated my server to CentOS 6.5 X64 version
I configured the machine usual
> yum install samba
I found out the samba service is ok from centos(server) to centos(client), but CentOS(server) <-> Win7(client) failed.
I can login and see files, but I can't copy files to the folder or edit it.
The root cause is that the protocol is changed by microsoft.
If you have the same question, do the following steps. It works for me.
Nothing is guaranteed.
> yum remove 'samba*'
> yum install samba4* krb5* -y
and according to the following setup
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak //備份一下samba的配置文件,
vim /etc/samba/smb.conf
下面綠色字體为原有的,粟色字體的为增加的,藍色字體为修改的
#======================= Global Settings =====================================
[global]
dos charset = GB2312
unix charset = GB2312
display charset = GB2312
# ----------------------- Network Related Options -------------------------
workgroup = MYGROUP --改为--> WORKGROUP //指定機器在網络上所屬的NT域名或組名(可改可不改)
server string = Samba Server Version %v //此選項是可選的,主要作用是Samba服務Windows系統注釋
netbios name = MYSAMBA //這個改不改隨意,它就象windows裏的機器名
interfaces = lo eth0192.168.88.35/24 //這裏寫本機IP地址,如果有多個網络也可以寫多個IP
hosts allow = 127.192.168.88. //設定允許訪問samba的IP地址或IP地址範圍
wins support = yes //設定samba提供WINS服務,通常無特殊原因設为no,除非所處網络上沒有主機提供WINS服務且需要samba提供WINS服務是才設yes
dns proxy = yes --改为--> no
name resolve order = wins host lmhosts bcas
bind interfaces only = yes
# --------------------------- Logging Options -----------------------------
log file = /var/log/samba/log.%m // log會在此目錄中为每個登陆用戶(Samba用戶)建立不同的日志文件
log level = 2
max log size = 500
# ----------------------- Standalone Server Options ------------------------
security = user //設定安全級別为user
passdb backend = tdbsam --改为--> smbpasswd:/etc/samba/smbpasswd
# --------------------------- Printing Options -----------------------------
load printers = yes
cups options = raw
#============================ Share Definitions ==============================
#如果注釋掉了[homes]則用戶就看不到自己的家目錄
#[homes]
# comment = Home Directories
# browseable = no
# writable = no
#; valid users = %S
#; valid users = MYDOMAIN\%S
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[share]
comment = Share //定義共享目錄名稱,可用任意字符串
path = /home/share //設定共享目錄路徑
public = no //指定該共享是否允許guest账戶訪問
available = yes //用來指定該共享資源是否可用
admin users = itadmin //指定該共享的管理員,對該共享具有完全控制權限,如果用戶驗證方式設置成“security=share”時,此項無效。
valid users = +mgr,+periphery,+filemgr //用來指定允許訪問該共享資源的用戶,單個用戶就直接寫用戶名,組就是“+組名”
writable = yes //是否允許寫入,這項對下面的幾項來說是首選,這項設置为NO,下面的create mask directory mask 等一系列預設值無效
write list = +mgr,+periphery,+filemgr //指定在該共享下有寫入權限的用戶
create mask= 0755 //表示新建文件的預設值,文件所有者全部權限,組內用戶及其他用戶可讀可執行
directory mask= 0755 //表示新建目錄的預設值,目錄所有者全部權限,組內用戶及其他用戶可讀可執行
browseable = no //指定該共享是否可以瀏覽
[project]
comment = project
path = /home/project
public = no
available = yes
admin users = itadmin
writable = yes
write list = +periphery
valid users = +periphery
create mask= 0755
directory mask= 0755
browseable = no
[projectmgr]
comment = projectmgr
path = /home/projectmgr
public = no
available = yes
admin users = itadmin
writable = yes
write list = +mgr
valid users = +mgr
create mask= 0755
directory mask= 0755
browseable = no
[filemgr]
comment = filemgr
path = /home/filemgr
public = no
available = yes
admin users = itadmin
writable = yes
write list = +filemgr
valid users = +filemgr
create mask= 0755
directory mask= 0755
browseable = no
配置完後通過testparm來檢查
說明一點:
samba3.x的早期版本默認使用tdb庫也就是smb.conf默認設定为passdb backend = tdbsam,只需要注釋掉該行添加smb passwd file = /etec/samba/smbpasswd即可使用smbpasswd存儲加密密鑰。從samba3.5.6開始samba規範了passdb backend参數的使用,取消了smb passwd file設定,如果簡單注釋掉passdb backend参數,密鑰文件也不會被存儲到smbpasswd。所以很多人說怎麼修改smb.conf的配置,smbpasswd文件都無法生成,就算手工創建,內容也是0字節。要用傳統的文本方式存儲只需這样設定passdb backend = smbpasswd:/etc/samba/smbpasswd(後面跟的是絕對路徑)>,不要再寫smb passwd file = /etc/samba/smbpasswd,該参數已經不适用於新版本的samba了。
启動smb及nmb服務
service smb start
service nmb start
nmb 是Samba 的主要启動服務器,讓其它機器能知道此機器共享了什麼;如果不打開nmb服務器的話,只能通過IP來訪問
注意:在Samba服務器運行其間,更改了配置最好用service smb reload命令,不要用restart,這样可以防止用戶在連接的過程中被中斷
將smb與nmb加入启動服務
chkconfig --level 35 smb on
chkconfig --level 35 nmb on
查看端口
netstat -antup |grep smb
netstat -antup |grep nmb
第五步:設置用戶
smbpasswd -a itadmin
New SMB password:
Retype new SMB password:
Added user itadmin.
注:如果想要讓/etc/samba/sabpasswd生效,要先启動samba,不然還是以默認的tdbsam方式來記錄密碼
刪除用戶:smbpasswd -x username
更改用戶密碼:smbpasswd username
沒有留言:
張貼留言