----------------------------
第一部分:編譯安裝
1.解壓
# tar xvzf samba-3.3.3.tar.gz
2.配置
#cd cd /test/samba-3.3.3/source/ --test為儲存samba壓縮檔案的目錄
#./configure --prefix=/usr/local/samba --with-acl-support
By default, `make install' will install all the files in
`/usr/local/samba/bin', `/usr/local/samba/lib'
3.編譯
#make
4.安裝
#make install
預設将samba安裝到/usr/local/samba中。
5.複制samba配置檔案樣例到//usr/local/samba/lib下
# pwd
/test/samba-3.3.3/examples
# cp smb.conf.default /usr/local/samba/lib/smb.conf
6.建立需要的目錄
#mkdir /etc/samba
7.連結smb配置檔案
#ln -s /usr/local/samba/lib/smb.conf /etc/samba
8.建議備份smb.conf配置檔案
#mkdir /backup
#cp /usr/local/samba/lib/smb.conf /backup
----------------------------------------------------------------------
第二部分:實驗配置
【案例說明】
1、所有員工都能夠在公司内流動辦公,但不管在哪台電腦上工作,都要把自己的檔案資料儲存在samba檔案伺服器上。
2、市場部,技術部都各有自己的目錄,同一個部門的人共同擁有一個共享目錄,其他部門的人都隻能通路在伺服器上自己個人的home目錄。
3、所有使用者都不允許使用伺服器上的shell。
【案例分析】
1、需要samba作為檔案伺服器,為所有使用者建立賬号和目錄,使用者預設都在伺服器上有一個home目錄,隻有認證通過才能看到。
2、需為市場部和技術部建立不同的組sales和tech,并且配置設定目錄,把所有市場部員工加入sales組,技術部員工加入tech組,通過samba共享sales和tech
3、建立使用者賬号時,不配置設定shell
(1).編輯smb.conf,設定安全級别為user級别。預設情況下就是user安全級别
security = user
smb passwd file=/etc/samba/smbpasswd
(2)建立市場部sales和技術部tech的組與使用者,并加入使用者到相應組,禁止登陸shell
#groupadd sales
#groupadd tech
#useradd -g sales -s /bin/false wind
#useradd -g sales -s /bin/false snow
#useradd -g tech -s /bin/false mary
#useradd -g tech -s /bin/false tiger
(3)建立ITG組和使用者,并加入到對應的組,禁止登陸shell
#groupadd ITG
#useradd -g ITG -s /bin/false scott
#useradd -g ITG -s /bin/false silver
(4)批量添加使用者為samba使用者,并設定密碼。這裡預設為123
#cd /usr/local/samba
#for user in wind snow mary tiger scott silver
do
smbpasswd -a $user
done
New SMB password:
Retype new SMB password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
Added user wind.
Added user snow.
Added user mary.
Added user tiger.
Added user scott.
Added user silver.
(5)建立組共享檔案夾并設定權限
#mkdir /home/sales /home/tech
#chgrp sales /home/sales
#chgrp tech /home/tech
#chmod 770 /home/sales
#chmod 770 /home/tech
#chmod g+s /home/sales
#chmod g+s /home/tech
(6)變價smb.conf,添加共享檔案夾并做對應設定
#vi /etc/samba/smb.conf
[sales]
path=/home/sales
comment=sales
public=no
valid users=@sales
write list=@sales
create mask=0770
directory mask=0770
[tech]
path=/home/tech
comment=tech
valid users=@tech
write list=@tech
(7)啟動samba
#/usr/local/samba/sbin/nmbd -D
#/usr/local/samba/sbin/smbd -D
/***********************
常見錯誤:
/usr/local/samba/sbin/nmbd: error while loading shared libraries: libtalloc.so.1: cannot open shared object file: No such file or directory
# vi /etc/ld.so.conf
或則
#echo "/usr/local/samba/lib " >>/etc/ld.so.conf
在該檔案後添加如下内容:
/usr/local/samba/lib
#ldconfig
*******************************/
(8)将samba添加到啟動腳本,實作開機自動啟動samba服務
#echo "/usr/local/samba/sbin/nmbd -D" >>/etc/rc.d/rc.local
#echo "/usr/local/samba/sbin/smbd -D" >>/etc/rc.d/rc.local
#cat /usr/local/samba/var/log.smbd
#cat /usr/local/samba/var/log.nmbd
[2009/04/09 12:50:55, 0] smbd/server.c:main(1267)
smbd version 3.3.3 started.
Copyright Andrew Tridgell and the Samba Team 1992-2009
[2009/04/09 12:50:55, 0] param/loadparm.c:lp_do_parameter(7230)
Global parameter smb passwd file found in service section!
(9)建立測試檔案
# ls /home/sales/
# cat >/home/sales/s.txt
hello, welcome to sales public department!
# ls /home/tech/
# cat >/home/tech/t.txt
hello, here is tech location!
(10)隻是允許某些IP能通路
hosts allow = 192.168.11.1 192.168.11.2