Title: Implement a Samba Server
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Implement a Samba Server

- Prepare the media, if needed, for the samba shares.
  - If a new media device is being installed, create the partition or logical volume to be used.
  - Format the unit with ext4 or another journaling filesystem.
  - Mount the new filesystem and ensure there are no errors, then set the filesystem to automount in the /etc/fstab file.
- Set permissions on files and directories as needed.  By default, /home should have the right permissions if users' home directories are to be shared.
- Install samba and edit the configuration file.

yum install samba
vi /etc/samba/smb.conf

- Update the name of the workgroup and the server string.

workgroup = MYGROUP
sever string = Samba Server Version %v

- If a local user database is to be used, keep the following lines.

security = user
passdb backend = tdbsam

- If a Windows domain controller is to be used, uncomment the following lines.

;        security = domain
;        passdb backend = tdbsam
;        realm = MY_REALM
;        password server = <NT-Server-Name>

- If network printing is to be allowed, keep the following lines.

load printers = yes
cups option = raw

- If operating system users will be given access to their home directories, keep these lines.

[homes]
comment = Home Directories
browseable = no
writable = yes

Note: It is possible to restrict access to individual users or grant access to groups.  See "man smb.conf" for more information about smb.conf options.

- Start the smb service and  ensure that it runs at boot.  Test that you can connect to it.  Note that currently there are no users, so press Enter at password prompt for an anonymous login.

service smb start
chkconfig smb on
yum install samba-client
smbclient -L //localhost

- The final step is to create samba users.  It is often convenient if the samba account has the same password as the operating system user of the same name, although this isn't required.  Note that the "-a" flag is given to smbpasswd to add a new user.  If the "-a" is missing, it will update the password for the given user.  See the man page for more details.

smbpasswd -a carl

- Verify that you can connect as that user and see what shares are available.

smbclient -U carl -L //localhost