BSD家族大觀 --2. OpenBSD
2024-07-26 00:29:08
供稿:網友
前言
SAMBA是一種能把 FreeBSD 的目錄開放給Microsoft Windows 95/98/NT
利用網路芳鄰方式存取的軟體集。其實并不只針對 FreeBSD,
其它UN*X 也都可以使用,這對工作平臺大部分時間是Microsoft family的人
在存取檔案上,會是個比較方便的選擇。
安裝SAMBA 2.0.6
1.先以 root 身份 login,切換至/usr/ports/net/samba 準備安裝SAMBA。
安裝時只要在 SAMBA 的目錄下執行 make install 即可
# root@ohaha[~] cd /usr/ports/net/samba/
# root@ohaha[/usr/ports/net/samba] make install
若無出現錯誤訊息則是安裝完成,你可順手將安裝過程中解開的source清掉。
# root@ohaha[/usr/ports/net/samba] make clean
設定 SAMBA (smb.conf)
在安裝完 SAMBA 後,它會放一份設定檔例在/usr/local/etc 下,
先將例一份來修改成我們要的設定。
# root@ohaha[~] cd /usr/local/etc/
# root@ohaha[/usr/local/etc] cp smb.conf.default smb.conf
sam.conf.default是設定 SAMBA 的例檔,真正讀取的預設是 smb.conf,
為了保留原始的例檔以供日後參考用,所以我們用 cp 的方式出設定檔,
大致瀏覽過 smb.conf 後發現,它主要分成三大設定區,[globe]、[homes]、
[PRinters],我沒有印表機,所以沒機會試[printers]相關部分。
我開 SAMBA 的目地是為了方便存取管理 ftp 并使用該臺 FreeBSD 上
的硬碟空間,所以等會設定檔的最終目地便是開出一個分享目錄 ftp,
無須密碼,但只允許我的工作機器去存取它。
在 smb.conf 中,所有的#和;都是解。#後接的是說明,
;後接的是指令,預設不打開該項設定,若想讓它生效把分號拿掉即可。
以下只引出我有動過的地方,沒提出的就是保留預設值。
#======================= Global Settings =====================================
[global]
# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
# 設定所在工作群組
workgroup = center
# server string is the equivalent of the NT Description field
# 該主機的解
server string = blah~
# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
# 允許連線的主機,允許 163.16.1.99 和 127.*.*.* 連線
hosts allow = 163.16.1.99 127.
# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
# 我沒有 printer ,所以有關 printer 的都會關掉
; load printers = yes
# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
# 這里設定免密碼的帳號,你設什麼帳號,連進來的 client就是那個身份,了嗎?
# 所以我把這兒改成 ftp 這個帳號,因為我 share 出來的目錄 owner 是 ftp
# 這樣我才能以免密碼又是 ftp 的身份對目錄有完整的存取權。
# 不過記得,這兒填的帳號必須存在 /etc/passwd 中,否則會以 nobody 的身份簽入。
guest account = ftp
# this tells Samba to use a separate log file for each machine
# that connects
# 把 log 建個目錄來放比較整齊,記得去 mkdir /var/log/samba 這個目錄。
log file = /var/log/samba/log.%m
# Security mode. Most people will want user level security. See
# security_level.txt for details.
# 設定安全層級,若要不用密碼分享的話就要設成 share ,若設 user 的話會要求密碼。
# 詳情請見 docs/security_level.txt
security = share
# You may wish to use passWord encryption. Please read
# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
# Do not enable this option unless you have read those documents
# 我的目的是不用密碼存取,所以這項開不開都沒影響,但若你想用密碼來控制存取權限時,
# 請記得將此項打開,因為...詳見 docs/ENCRYPTION.txt, Win95.txt 和 WinNT.txt。
; encrypt passwords = yes
# for Traditional Chinese Users
# 若你想看到中文目錄、檔名的話,把 client code page=950 前的分號拿掉,
# 注意,coding system 那項留著別打開它,兩個都打開的話反而會看不到中文
client code page=950
; coding system=cap
#============================ Share Definitions ==============================
# 接下來這一段就是 [homes] 和 [printers] 以及其它任何你想 share 出來的目錄設定
# 區,我把 [homes] 也 mark 起來了,因為我不想 share 任何 home 出來。
;[homes-%U]
; comment = Home Directories
; path = /home/%U
; user = %U
; browseable = no
; writeable = yes
# ftp
# 我加了這段,將 ftp 的目錄開分享。一開始我們看到的 [ftp] 就是你分享出來的目錄
# 在 95/98/NT 中會看到的資料夾名稱,path 指向欲 share 目錄的絕對路徑,
# public = yes 是指定這個分享不須密碼,writeable = yes 是指可對該分享做寫入動作
# 注意一點,當有 public = yes 這行時,對該分享存取的身份就是之前在 [globe] 區,
# 我們所設定 guest account 的身份,若剛剛 guest account 沒改成 ftp,那麼現在
# 即使有設 writeable = yes 也會因為 owner 不對而無法寫入。
[ftp]
path = /home/ftp
public = yes
writeable = yes
啟動 SAMBA
在安裝完 SAMBA 後,它丟了個啟動的 script 在 /usr/local/etc/rc.d/,
檔名是 samba.sh.sample,將之更名并 chmod 成可執行。
# root@ohaha[/usr/local/etc/rc.d] mv samba.sh.sample samba.sh
# root@ohaha[/usr/local/etc/rc.d] chmod 750 samba.sh
你現在可以重新開機或者手動執行 samba.sh 來啟動 SAMBA。
# root@ohaha[~] /usr/local/etc/rc.d/samba.sh
測試 SAMBAuh...接下來的不用說了吧,趕快用 95/98 的網路芳鄰看看是否能成功
看到并存取分享出來的目錄。