Homework 5 b Samba Computer Center CS NCTU
Homework 5 b: Samba
Computer Center, CS, NCTU 2 Network-based File Sharing (1) q NFS (UNIX-based) • mountd is responsible for mount request • nfsd and nfsiod q CIFS (Microsoft) • Common Internet File System • 網路芳鄰
Computer Center, CS, NCTU Network-based File Sharing (2) q Difference between local filesystem and network filesystem when accessing • Net. BIOS (API) Ø Used to share or access network-based filesystem just as BIOS does in local filesystem Net. BIOS 3
Computer Center, CS, NCTU 4 Network-based File Sharing (3) • Net. BEUI (transport protocol) Ø Transfer Net. BIOS commands across network Ø Each host can claim a name not used in network – Net. BIOS Name Server or not
Computer Center, CS, NCTU 5 Network-based File Sharing (4)
Computer Center, CS, NCTU 6 UNIX-Windows communication q SAMBA • A UNIX application that speak SMB protocol • Designed by Andrew Tridgwell, in 1991 • Original Name: Server Message Block (SMB)
Computer Center, CS, NCTU 7 What SAMBA can do? q Sharing • Sharing files or printers just like Microsoft does • Authenticate user identity just like Microsoft does • Resolve Net. BIOS name just like Microsoft does
Computer Center, CS, NCTU 8 Install SAMBA q Using ports • % cd /usr/ports/net/samba • % make; make install; make clean
Computer Center, CS, NCTU SAMBA components q Configuration files • /usr/local/etc/smb. conf. default /usr/local/etc/smb. conf • /usr/local/etc/lmhosts q Major execution files • smbd (/usr/local/sbin/smbd) Ø Management of sharing directories, files and printers • nmbd (/usr/local/sbin/nmbd) Ø Resolve Net. BIOS name and manage workgroup • smbpasswd (/usr/local/bin/smbpasswd) Ø Change a user’s SMB password 9
Computer Center, CS, NCTU SAMBA configuration file q smb. conf • Three sections Ø Global Setting Ø Printer Sharing Setting Ø Home Sharing Setting # comments [global] para 1 = value 1 … [printers] para 2 = value 2 … [homes] para 3 = value 3 … [share-dir] para 4 = value 4 … 10
Computer Center, CS, NCTU SAMBA configuration file – Global Setting (1) q Global Configuration • workgroup Ø Group name to join Ø Ex: workgroup = chwong • server string Ø Description of this host Ø Ex: server string = Samba Server of SA Course • netbios name Ø Net. BIOS name of this host Ø Ex: netbios name = sabsd • Charset Settings Ø “display charset”, “unix charset”, “dos charset” Ø Ex: display charset = CP 950 unix charset = CP 950 dos charset = CP 950 • hosts allow Ø Apply to all services, regardless or individual service setting; Ø Ex: hosts allow = 140. 113. 235. , 140. 113. 11
Computer Center, CS, NCTU SAMBA configuration file – Global Setting (2) • guest ok (or public = yes) Ø If this is yes, no password is required Ø Ex: guest ok = no • guest account Ø If guest can use this samba service, any guest request will map to this guest account Ø Ex: guest account = ftp • log file Ø Full path of log file Ø Ex: log file = /var/log/samba/log. %m • max log size (KB) Ø Ex: max log size = 500 12
Computer Center, CS, NCTU 13 SAMBA configuration file – Global Setting (3) • security = [share/user/server/domain] Ø share: no need of id and password to login Ø user: default option, login with id and password Ø server: check id and password by another server Ø domain: check id and password by domain controller Ø Ex: – security = user – passdb backend = tdbsam
Computer Center, CS, NCTU 14 SAMBA configuration file – Global Setting (4) q Example of global setting [global] workgroup server string netbios name display charset unix charset dos charset printcap name load printers printing log file max log size security passdb backend = chwong = sabsd samba server = sabsd = CP 950 = /etc/printcap = yes = cups = /var/log/samba/log. %m = 500 = user = tdbsam
Computer Center, CS, NCTU Samba parameters q Default parameters in samba • %m Ø Client Net. BIOS name • %M Ø Client Hostname • %I Ø Client IP • %L Ø Samba server Net. BIOS name • %h Ø Samba server Hostname • %H Ø User home directory • %U Ø Login name • %T Ø Current Date time 15
Computer Center, CS, NCTU SAMBA configuration file – Home Sharing Setting (1) q Home sharing setting • comment Ø Description of this directory • path Ø Sharing directory path • browseable Ø Display sharing name or not • read only , writeable • write list Ø Only users on this can write content if read only • create mode / create mask Ø Default permission when file is created • directory mode / directory mask Ø Default permission when directory is created • guest ok (or public = yes) 16
Computer Center, CS, NCTU 17 SAMBA configuration file – Home Sharing Setting (2) q Example of home sharing [Image] comment path read only public writable create mode directory mode = Book Picture = /home/image = no = yes = 0664 = 0775
Computer Center, CS, NCTU 18 Starting SAMBA q Script • /usr/local/etc/rc. d/samba. sh {start|stop}
Computer Center, CS, NCTU SAMBA password q smb password file • Now samba stores accounts and passwords in tdb Ø Default database path: /var/db/samba q smbpasswd command • -a Ø Add new user • -d Ø Let some account in smbpasswd file can not login (to disable) • -e Ø Let some disable account resume (to enable) 19
Computer Center, CS, NCTU 20 Tool: smbclient (1) q A client program that can talk to an SMB server q Usage: • -L [hostname] Ø List sharable resource • -U [username] Ø Login with username
Computer Center, CS, NCTU 21 Tool: smbclient (2) sabsd [/home/chwong] -chwong- smbclient -L sabsd -U chwong Password: Domain=[SABSD] OS=[Unix] Server=[Samba 3. 0. 23 c] Sharename Type ------Image Disk IPC$ IPC ADMIN$ IPC Domain=[SABSD] OS=[Unix] Comment ------Book Picture IPC Service (sabsd) Server=[Samba 3. 0. 23 c] Server ----- Comment ------- Workgroup ----- Master -------
Computer Center, CS, NCTU 22 SWAT (1) q Edit /etc/inetd. conf • Unmark swat stream tcp nowait/400 q Restart inetd q Browse http: //sabsd. cs. nctu. edu. tw: 901/ root /usr/local/sbin/swat
q Root access Computer Center, CS, NCTU 23 SWAT (2)
- Slides: 23