This is the second post of our series about installing, configuring and managing Samba in Ubuntu Linux. The first post can be found here.
In this post, we’re going to show you how to add Samba user so that the user can access shares on Ubuntu or Linux machine from a remote computer. Adding Samba user is important because without it, it might prevent the user from accessing shares from a remote computer.
Samba has an access control list (smbpasswd file) of users who should have access to Samba shares. These users must already be active on the Linux machine before they can be added to Samba user list.
If a user does not have an account on the machine, he/she can’t be added to smbpasswd file.
Adding Samba user on Ubuntu Server
To add Samba user on Ubuntu server, open the terminal and run the commands below.
smbpasswd -a username
username should be replaced with the actual user account name.
When you run the command above, it should prompt you to create a password for the user. Create one, maybe one that matches your Ubuntu account password.
Next, to give the user access to a particular share, open the smb.conf file at /etc/samba/smb.conf and create share as followed below.[database]comment = Database Filepath = /data/databasevalid users = usernamepublic = nowritable = yes
replace username with the actual account name and save the file.
Adding Samba user on Ubuntu Desktop
The above steps above should also work on Ubuntu desktops. However, since most desktop users use GUI to manage stuff, open Samba from Unity Dash.
Next, select Preferences –> Samba Users
Then click ‘Add’ and select an existing user account, then create the Windows username and password for the account. This is the same as what we did for Ubuntu server setup.
To give the user access to shares, create a share and select Access tab, then select the username you wish to have access to the shares and save.
This is how Samba users are create and provided access to resources.