Quick samba server with authentication setup
Home > CentOS > CentOS 6.x > Samba server configuration > Quick samba server with authentication setup
Configure authentication based sharing
To configure samba server with authentication based shares, use following steps:
- Disable SELinux
- yum -y install samba
- Edit /etc/smb.conf so that it only contains:
- [global]
- workgroup = WORKGROUP
- server string = Samba Server Version %v
- netbios name = files.sbarjatiya.com
- log file = /var/log/samba/log.%m
- max log size = 50
- security = user
- passdb backend = tdbsam
- load printers = no
- service smb start
- chkconfig smb on
- service nmb start
- chkconfig nmb on
Add samba user
To add a new samba user use:
- useradd <username>
- smbpasswd -a <username>
Change samba password of existing user
To change password of user after it has been added use 'smbpasswd <username>'. Linux clients can also change password remotely using 'smbpasswd -r <samba-server-ip> -U <samba-username>'
To create a secured samba share append following configuration in /etc/samba/smb.conf
[<share-name>] comment = <Comment> path = <absolute-path-of-folder> public = yes writable = yes read only = no valid users = <space-separated user names>
Then create the folder with configured path with 777 permissions. Note that if 777 is not feasible giving ownership to user nobody might also suffice. Restart samba using
service smb restart
Use "smbclient -U username //<server-ip>/<share-name>" and enter samba user's password. Use 'help' on 'smb>' prompt to learn how to use smb.
Use \\<server-ip>\<share-name> and login with samba user id and password to access the share
Note that in Windows credentials get cached for the current login. To remove cached credentials there are two options:
- Log off from current Windows user and re-login
- Other option is to:
- Open 'cmd'
- Type 'net use' to see currently used shares
- Type 'net use \\<server-ip>\<share-name> /delete' where '\\<server-ip>\<share-name>' should have been displayed in output of previous 'net use' command.
Supporting change of Samba password from windows clients
Linux or MAC clients can easily change passwords as described earlier using 'smbpasswd -r <samba-server> -U <samba-user>'. However for Windows clients there is no easy way to change samba password. To provide a web based administrative interface to reset samba passwords use following steps:
Install webmin
First install webmin using:
- Download webmin
- yum localinstall webmin*.rpm
- service webmin start
- chkconfig webmin on
- Set root password
- Access webmin user interface at https://<server-ip>:10000/
- Login using root user
Create user for samba password reset
Then create user account for resetting samba password using:
- Select Webmin -> Webmin Users from left panel
- Click "Create a new webmin user" option on right
- Give appropriate username desired for webmin user which would be used to reset samba passwords, eg. samba
- Set webmin user password.
- Click available webmin modules
- Choose 'Samba Windows File Sharing'
- Click 'Create'
Reduce access of samba password user to only change of password
Restrict access of user to only reset user samba password using:
- Click on 'samba' or appropriate username on webmin users webpage.
- Click on 'Available webmin modules'
- Click on "Samba Windows File Sharing". In this case click on the name which is hyperlink and not on the checkbox in front of the name.
- Select no for everything except
- Can view SAMBA users database?
- Can edit SAMBA users?
- Even for Access file shares, Access print shares untick all three - create, read, write.
- Click "Save"
- Use "Switch to user" option to verify settings. Refresh page after clicking "Switch to user" for new settings to take effect.
Home > CentOS > CentOS 6.x > Samba server configuration > Quick samba server with authentication setup