1 / 26

網路伺服器應用 Linux Server

網路伺服器應用 Linux Server. Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology andres@dlit.edu.tw http://www.cse.dlit.edu.tw/~andres. Chapter 19 簡易 SAMBA 伺服器設定. 19.1 原理. Unix Like 的機器 Network File System, NFS Microsoft

wan
Download Presentation

網路伺服器應用 Linux Server

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 網路伺服器應用Linux Server Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology andres@dlit.edu.tw http://www.cse.dlit.edu.tw/~andres

  2. Chapter 19簡易 SAMBA 伺服器設定

  3. 19.1 原理 • Unix Like 的機器 • Network File System, NFS • Microsoft • Common Internet File System, CIFS • 網路上的芳鄰 • Unix 與 DOS • Server Message Block (SMB) 檔案系統

  4. SAMBA • 分享檔案 • 印表機服務 • 提供使用者登入 SAMBA 主機時的身份認證 • 可以進行 Windows 網路上的主機名稱解析 (NetBIOS name) • 可以進行裝置的分享 • Zip, CDROM...

  5. NetBIOS protocol • SAMBA 檔案系統架構在 NetBIOS • Network Basic Input/Output System 通訊協定(NetBIOS) • IBM 發展 • NetBIOS over TCP/IP

  6. 連線模式 • peer/peer • Workgroup model • 資源分享 • Windows『網路上的芳鄰』的『工作群組』架構 • domain model • 所有的帳號與密碼都放置在一部主控電腦 ( Primary Domain Controller, PDC ) • 由 PDC 主機辨識後,才給予適當的使用權限

  7. 19.2 套件安裝 • Samba • SAMBA 的主要 daemon 檔案 ( smbd 及 nmbd ) • SAMBA 的文件檔 ( document ) • 其他與 SAMBA 相關的 logrotate 設定檔及開機預設選項檔案 • samba-common • SAMBA 的主要設定檔 (smb.conf) • smb.conf 語法檢驗的測試程式 ( testparm ) • samba-client • Linux 做為 SAMBA Client 端時,所需要的工具指令

  8. 套件安裝 • rpm -qa | grep samba samba-common-2.2.7a-8.9.0 redhat-config-samba-1.0.4-1 samba-2.2.7a-8.9.0 samba-client-2.2.7a-8.9.0

  9. 19.3 Server 端的設定 • SAMBA 的套件結構 • SAMBA 的設定檔 • /etc/samba/smb.conf • /etc/samba/lmhosts • /etc/samba/smbpasswd • SAMBA 的執行檔 • SAMBA 的相關目錄

  10. SAMBA 的執行檔 • smbd, nmbd • testparm • 查看一下 SAMBA 的所有設定參數與 smb.conf 的設定項目是否正確 • smbpasswd • 建立 SAMBA 的密碼 • smbclient • 查看別台電腦所分享出來的目錄與裝置時 • 在自己的 SAMBA 主機上面,用來查看是否設定成功 • smbmount

  11. SAMBA 的相關目錄 • /usr/share/doc/samba • 技術手冊 • /var/log/samba • 預設的登錄檔放置目錄 • /usr/share/samba/codepages • 各個語言的支援格式 • codepage.950

  12. 1. 設定流程 • 設定檔 smb.conf • 是否需要密碼、是否支援 PDC • 設定分享的目錄與該目錄的屬性 • smbpasswd • 建立使用者的帳號與密碼 • 啟動 smb 服務 • /etc/rc.d/init.d/samba restart

  13. /etc/samba/smb.conf • [global] • Workgroup:工作群組 • netbios name: 主機名稱 • server string:主機的說明 • Security:規定 SAMBA 主機的安全登入項目 • share :不進行安全登入,即沒有設定帳號與密碼 • user :設定主機的密碼檔作為登入的驗證檔案 • domain :SAMBA 作為 PDC • log file:登錄檔放置的目錄所在喔

  14. Example • [global]    workgroup = 2cs31    server string = 2cs31 Linux Samba Server    netbios name  = 2cs31xxxxxxx    client code page = 950   log file = /var/log/samba/log.%m    max log size = 500    security = user    encrypt passwords = yes    smb passwd file = /etc/samba/smbpasswd    socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

  15. SAMBA 的變數值 • %S:取代目前的設定項目值 • [homes]   valid users = %S • valid users 是允許的登入者 • 設定為 %S 表示任何可登入的使用者都能夠登入 • test 使用者登入之後, [homes] 就會自動的變成了 [test] • %m:代表 Client 端的 NetBIOS  主機名稱喔 • %M:代表 Client 端的 Internet 主機名稱喔 • %L:代表 SAMBA 主機的 NetBIOS 主機名稱 • %H:代表使用者的家目錄 • %U:代表目前登入的使用者的使用者名稱 • %g:代表登入的使用者的群組名稱

  16. /etc/samba/smb.conf • [Directory] • comment :目錄的說明 • path:Linux 檔案系統裡面的目錄 • read only:是否唯讀 • public:是否讓所有可以登入的使用者看到這個項目 • writable :是否可以寫入 • 如果 writable 跟 read only 互相抵觸!最後出現的設定值為主要的設定 • create mode • directory mode

  17. Example • [Webpage]    comment      = My Home Page    path         = /var/www/html    read only    = no    public       = yes    writable = yes    create mode = 0664    directory mode = 0775

  18. 2. 沒有防備的 SAMBA 分享設定 • 工作群組 • workgroup=2cs31 • Linux 主機 NetBIOS 名稱 • netbios name=2cs31xxxxxxxx • 安全設定為沒有防備 • security =share • 分享 /tmp 目錄

  19. smb.conf [global]    workgroup = 2cs31    netbios name = 2cs31xxxxxxxx    server string = xxxxxxx’s SAMBA Server    client code page = 950 log file = /var/log/samba/log.%m    max log size = 0    security = share    socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 [tmp]    comment = Temporary file space    path = /tmp   read only = no    public = yes

  20. 測試 smb.conf 設定值與啟動 SAMBA • 測試 smb.conf 設定值 • Testparm • 啟動 SAMBA • /etc/rc.d/init.d/smb restart • netstat -tlunp | grep ':13‘ • 如果有設定防火牆,一定要去察看防火牆的設定是否已經啟動了 137 ~ 139 的登入

  21. Client 端的測試 • 本機自我測試 • smbclient -L //2cs31xxxxxxxx • 留意Linux 的檔案權限與 SAMBA 設定的權限關係 • 是否能夠使用,得視登入 SAMBA 的該使用者對於 Linux 的檔案系統是否有存取的權限

  22. 3. 需要使用者登入的設定 • 工作群組 • workgroup=2cs31 • Linux 主機 NetBIOS 名稱 • netbios name=2cs31xxxxxxxx • 安全設定為沒有防備 • security =user • 分享home directory • 分享目錄 /home/public 給所有使用者使用

  23. smb.conf [global] workgroup = 2cs31 netbios name = 2cs31xxxxxxxx server string = xxxxxxx’s SAMBA Server client code page = 950 log file = /var/log/samba/log.%m max log size = 0 security = user encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd   socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

  24. smb.conf (Cont.) • [homes]    comment = Home Directories    browseable = no    writable = yes    valid users = %S    create mode = 0664    directory mode = 0775 [public]    comment = Public Stuff    path = /home/public    public = yes    writable = yes

  25. 設定使用者帳號與密碼 • SAMBA 只是 Linux 底下的一套軟體,使用 SAMBA 來進行 Linux 檔案系統時,還是需要以 Linux 系統下的 UID 與 GID 為準則 • 在 SAMBA 主機所提供能夠登入的帳號,必須要在 /etc/passwd 裡面存在 • 不是所有在 /etc/passwd 裡面的帳號都可以用來登入 SAMBA 主機,必須要新增到 SAMBA 密碼設定檔裡面的帳號才可以使用SAMBA登入 • smbpasswd 指令

  26. 設定使用者帳號與密碼(Cont.) • /etc/samba • touch smbpasswd • chown root:root smbpasswd; chmod 600 smbpasswd • smbpasswd -a guest • testparm • /etc/rc.d/init.d/smb restart • smbclient -L //127.0.0.1  

More Related