File sharing dengan samba

Tuesday, December 2, 2008 21:11
Posted in category Linux

Samba adalah nama aplikasi untuk menangani protokol smb dan nmb di linux(nggak cuma di linux sih, bahkan di semua OS, asal bisa dicompile).

Protokol SMB digunakan untuk layanan berbagi pakai file dan printer

Protokol NMB digunakan untuk layanan domain manager dan wins (server penamaan NetBios)

Samba menjadikan mesin linux terbaca di protokol penamaan netbios di windows, sehingga mesin windows dapat mengenali mesin linux hanya dengan nama pendek seperti \\ws1 \\linux \\server dll

sehingga jika hendak di ping dari mesin windows pun bisa langsung dengan nama pendeknya

C:\>ping linux

Pinging linux [192.168.0.1] with 32 bytes of data:

Reply from 192.168.0.1: bytes=32 time<1ms TTL=64
Reply from 192.168.0.1: bytes=32 time<1ms TTL=64
Reply from 192.168.0.1: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.0.1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

Sedangkan NetBios adalah protokol koneksi jaringan(layaknya tcp/ip tapi dalam skup LAN) dengan identitas langsung nama komputernya (hostname) dan workgroup atau domain layaknya netmask.  Jadi tidak ada IP pun tetap bisa tersambung(tetapi tidak untuk semua aplikasi terkenal yang menggunakan tcp/ip)

coba diperiksa apa saja paket atau perintah-perintah yang berkenaan untuk smb ini di linux

server@Linux:~$ smb[tab]
smbcacls    smbcontrol  smbd        smbpasswd   smbstatus   smbtree
smbclient   smbcquotas  smbget      smbspool    smbtar

jika tidak ada maka kita perlu menginstallnya, (mudah-mudahan sudah ada)

kita tidak akan membahas menginstall paket samba disini( akan dibahas di tulisan lain)

dalam kasus ini kita ingin membagi pakai folder/direktory dan printer.

atur configurasi samba di /etc/samba/smb.conf berikut potongan-potongan smb.conf, yang kira-kira perlu.

server@Linux:~$ sudo pico /etc/samba/smb.conf
[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = HARITS
netbiosname = Linux

# server string is the equivalent of the NT Description field
#   server string = %h
server string = Ubuntu

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
;   wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.
dns proxy = yes

# What naming service and in what order should we use to resolve host names
# to IP addresses
name resolve order = lmhosts host wins bcast
#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
;   interfaces = 127.0.0.0/8 eth0
interface = 192.168.0.0/24 eth0
hosts allow = 192.168.0.
# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
security = user

#  guest account = nobody
invalid users = root

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
unix password sync = yes

# This option controls how nsuccessful authentication attempts are mapped
# to anonymous connections
map to guest = bad user

########## Printing ##########

# If you want to automatically load your printer list rather
# than setting them up individually then you’ll need this
load printers = yes
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = no
read only = yes
guest ok = yes
writable = nop
[data]
path = /opt/data
comment = Linux Shared Document\’s Folder
available = yes
browseable = yes
public = yes
writable = yes
guest ok = yes
veto files = /folder.htt/desktop.ini/folder.vtt/*.cmd/*.bat/*.vbs/*.eml/*.nws/riched20.dll/*.exe/autorun.inf/*.js/

Yang paling penting adalah, pada bagian [global], workgroup dan netbiosname komputer disini saya buat LINUX, silahkan buat yang lain, jangan ada nama yang sama di workgroup

pada bagian #### Networking ####

interface = 192.168.0.0/24 eth0
hosts allow = 192.168.0.

ini menentukan lewat interfaces mana komputer kita dikenali di jaringan netbios dan dari ip mana saja yang diperbolehkan tersambung.

kemudian pada bagian printer biasanya semua printer yang terdaftar pada CUPS (printer spooling server) akan disharing.

dan yang terakhir adalah folder mana yang hendak kita sharing

contoh di atas adalah folder /opt/data dengan nama sharingnya data sehingga jika diakses URLnya \\LINUX\data

sedangkan parameternya sangat mudah dipahami. seperti browseabl, jika di set no maka tidak terbaca di jika dicari secara broadcast. tapi masih terbuka jika diketikkan urlnya. parameter writable jika…

gara-gara speedy dudul jadi nggak kesimpan semua. capek ngetiknya cuma terimpan separuh, lupa udah sampe mana.

ada tambahan dikit, yaitu parameter yang paling saya sukai di samba ini, yang justru tidak ada di OS siempunya protokol smb (windows) adalah veto files, yang mana dengan veto file kita dapat membatasi file apa saya yang tidak boleh berada di folder sharing kita. Hati-hati dengan contoh di atas. karena folder anda tidak akan bisa untuk menyimpan file dengan ekstensi .exe

You can leave a response, or trackback from your own site.

Leave a Reply