星期四, 4月 26, 2007

SUSE Linux 下的 SAMBA 伺服器

SUSE Linux 下的 SAMBA 伺服器
基本上跟RedHat系列的設定差不多
只是預設分享的目錄有點不太一樣
RedHat 預設分享homes 及 printers兩個目錄
[root@localhost ~]# cat /etc/samba/smb.conf |grep '\[' | grep -v '^;' | grep -v '^#'

[global]
[homes]
[printers]

但是SUSE Linux 預設分享的資料夾比較多, 多了profiles users groups print$
故要注意安全性的問題
linux-lab:/etc/samba # cat smb.conf | grep '\['
[global]
[homes]
[profiles]
[users]
[groups]
[printers]
[print$]


上面的print$ 為印表機驅動程式的分享

若以samba來當PDC
可以直接用yast 來設定
Domain Controller 為Primary (PDC)
及設定workgroup 的名稱 (即網域名稱)
附註只要有跑過yast的設定來分享
那gobal的設定部份就會加上
add machine script = /usr/sbin/useradd -c Machine -d /var/lib/nobody -s /bin/false %m$

方便加入Windows的機器, 也就是說Windows的機器提出要求後, 系統會自動加入帳號, 非以往要手動建立帳號,
在RedHat那邊有此script 的設定, 只是註解起來

設定好PDC 之後, 相關性的設定會儲存在 /var/lib/samba
linux-lab:/var/lib/samba # pwd
/var/lib/samba

相關檔案如下
linux-lab:/var/lib/samba # ls
account_policy.tdb group_mapping.tdb ntprinters.tdb share_info.tdb
brlock.tdb locking.tdb perfmon unexpected.tdb
browse.dat messages.tdb printing usershares
connections.tdb netlogon profiles
drivers ntdrivers.tdb registry.tdb
gencache.tdb ntforms.tdb sessionid.tdb

觀察兩個目錄 profiles and netlogon
linux-lab:/var/lib/samba # ls profiles/
linux-lab:/var/lib/samba # ls netlogon/

Windows機器加入後會自動加入機器帳號
linux-lab:/var/lib/samba # tail -n 2 /etc/passwd
hacluster:x:90:90:heartbeat processes:/var/lib/heartbeat/cores/hacluster:/bin/false
student-max$:x:1001:100:Machine:/var/lib/nobody:/bin/false

Windows加入網域後,以linux 本機帳號登入後檢查
linux-lab:/var/lib/samba # ls profiles/
linux-lab:/var/lib/samba # ls netlogon/

登出 Windows機器後檢查
linux-lab:/var/lib/samba # ls profiles/
linux-lab:/var/lib/samba # ls netlogon/
還是沒有資料 ---------->這時候會發現與RedHat不同處

在RedHat系列,設定為
;[Profiles]
; path = /usr/local/samba/profiles
; browseable = no
; guest ok = yes

在SUSE Linux 設定為
[profiles]
comment = Network Profiles Service
path = %H
read only = No
store dos attributes = Yes
create mask = 0600
directory mask = 0700
其路徑在 %H
故存放的地點為 使用者家目錄下的 .msprofile 資料夾
故我們測試一下
在還沒使用 samba 服務登入Windows之前使用者家目錄
linux-lab:/home/max # ls
.bash_history .emacs .gnu-emacs .mozilla .urlview .xim.template Documents
.bashrc .exrc .inputrc .muttrc .xcoralrc .xinitrc.template bin
.dvipsrc .fonts .kermrc .profile .xemacs .xtalkrc public_html

登入Windows機器之後
linux-lab:/home/max # ls
.bash_history .exrc .kermrc .profile .xim.template bin
.bashrc .fonts .mozilla .urlview .xinitrc.template public_html
.dvipsrc .gnu-emacs .msprofile .xcoralrc .xtalkrc
.emacs .inputrc .muttrc .xemacs Documents
linux-lab:/home/max # ls .msprofile/

多了.msprofile資料夾,但是是空的,因為登出才會回存^^
在Windows機器上, 於我的文件新增一個資料夾sakana測試
登出Windows機器觀察

linux-lab:/home/max # ls .msprofile/
Application Data My Documents PrintHood Templates ntuser.ini ??????
Cookies NTUSER.DAT Recent UserData ntuser.pol
Favorites NetHood SendTo ntuser.dat.LOG ?????????????????????

linux-lab:/home/max # ls .msprofile/My\ Documents/
My Music My Pictures desktop.ini sakana

果然有回存到samba伺服器上面
^^

沒有留言: