Samba: Sharing Files With Windows Hosts
Samba: Sharing Files With Windows Hosts
´ You can query shares on your local machine as well as on other SAMBA
based or Windows machines using the smbclient command
´ The syntax is as follows: smblcient –L host
´ Press ENTER when prompted for a password
´ If a name server is not available on the domain, you can start the SAMBA
name server by issuing service nmb start, which will provide NETBIOS names
for the hosts.
´ The output of this command shows the available directories and printers
offered by the queried host
Allowing access through iptables
´ If you are using the firewall, the following ports must be enabled on the
firewall:
´ 445 (TCP): this is the port on which smbd daemon listens
´ 139 (TCP): used for the NetBIOS hostname resolving
´ 137 and 138 (UDP): used by the nmbd daemon. Open them only if you intend to
use nmbd for incoming requests
´ By default, ESTABLISHED and RELATED packets should be enabled
Configuring shares
´ This section is used to give the system users access to their own home
directories via SAMBA. The following are the most important options:
´ browseable: hides SAMBA servers from being discovered (like from Network
Places in Windows).
´ writable: if set to yes, users can add and delete files in their home directories
´ valid users: if this value is commented out, any valid user on the system can log
on. However, if it is uncommented and set to %s this will restrict access to users of
the service (SAMBA users). It can be also preceded by a domain name like
MYDOMAIN\%s to restrict access to users of a specific domain.
The [printers] section
´ Printers that are configured using the CUPS protocol is available for network
printing by the SAMBA services if printable = yes.
´ If cups options = raw that means that SAMBA will let Windows clients use
their own drivers for printing. The shared printer will be just a raw one
´ Other options can be set like writeable and browseable, which provide the
same functionality as shared directories.
LAB: creating and using a SAMBA share
´ Target: create a shared directory that can be accessed by Windows hosts.
´ Create a directory that will be used as a SAMBA share /samba
mkdir /samba
´ Create a local user that will be the owner of this share
useradd joe
passwd joe
chown joe:joe /samba
´ Add this user to SAMBA users to be able to access the share:
smbapasswd –a joe
´ Add an entry to /etc/samba/smb.conf to configure the shared directory:
[Windows share]
comment = This is a test Windows share
path = /samba
read only = no
browseable = yes
valid users = joe
´ Restart the service to apply the changes
service smb restart
´ Try to access the shared directory from a Windows machine and ensure that you can read
and write files.