Sharing a directory with Samba



Sharing Files and Directories with Samba


Update the global section of configuration file smb.conf as below

[global]

workgroup = WORKGROUP

server string = Samba Server

netbios name = LinuxSamba

security = share


Enter the name of workgroup, put server string name as you wish, write the netbios name and security as share.


Security option

Security has many options as share, user, domain, ads and server.

Difference in these options:

User

In this mode Samba server accepts the username/password credentials passed by the user attempting to log in, the client will be able to mount the shares on the server.

Share

This mode basically means that a client attempts to authenticate against a share and, once authentication succeeds, that user will have access to only that share.

Domain

This method is used when accounts are stored on a centralized server - usually a Windows Domain Controller. This method requires all authentication requests to be passed through the domain controller. This method also requires an additional parameter (along with the "security = domain" line) that looks like:

workgroup = DOMAIN

where DOMAIN is the actual domain on the network.

This method also requires the machine connecting to have joined the domain and requires administrator credentials to do so.

Ads

This is for Active Directory. Samba does include the necessary tools with which to join an AD, but the Active Directory server must be running in Native Mode for this to work. The Samba server will also need to have a working Kerberos system installed, and the smb.conf fill will need the following extra configuration lines:

realm = KERBEROS.REALM

security = ADS


where KERBEROS.REALM is the actual realm configured within the Kerberos configuration file.

Server

This mode is generally thought of as a severe security issue and no longer used. This method sends username/password credentials to yet another server for authentication. The problem with this method is if that third machine is down, no authentication can take place. The real security issue happens because, once authentication is made, the connection is left open for extended periods of time -- this means there is the possibility of three machines being left open at once.



Sharing a directory


For sharing a Directory add below configuration in smb.conf


[share]

path = /home/samba/share

comment = samba file share

read only = yes

guest ok = yes


This is configuration for readonly server, for writable server replace readonly with

writable = yes

or

read only = no


First make a directory share at a path you want to share in given example( /home/samba/share) and give appropriate permission (like 755 for readonly path, 777 for writable path). Inside directory put the file to share.


Now restart the server

# service smb restart

Shutting down SMB services: [ OK ]

Shutting down NMB services: [ OK ]

Starting SMB services: [ OK ]

Starting NMB services: [ OK ]




Verify the server using command

smbclient -L 127.0.0.1


Verify on windows: on Microsoft windows computer use the net use command to mount the share on the driveletter let L.

C:\>net use L: \\LinuxSamba\share

The command completed successfully.

Then we test looking at the contents of the share, and reading the files.

C:\>dir L:

It will show the content of shared directory.





More on Samba Server


No comments: