Samba: How to set passwords for the users in the username map

samba

I want to map a large number of login usernames to a few unix users, so I guessed the username map config option is an appropriate way.

I enabled it for a particular share in smb.conf:

security = share
[some_share]
username_map = /etc/samba/some_share.map

and added all the usernames to the map:

some_share_user = anton berta caesar ...

But how do I set the passwords for those users?

# smbpasswd -a anton
New SMB password:
Retype new SMB password:
Failed to add entry for user anton.

Though it doesn't say so explicitly, I guess this is because smbpasswd checks if there is a matching unix user and forgets to check all the username maps, too.

Best Answer

The document you linked to explicitly states

Please note that for user or share mode security, the username map is applied prior to validating the user credentials.

This means that you will have to set a shared password for some_share_user and make anton, berta, and caesar log in with that password.

It works exactly the opposite way if anton, berta, and caesar are users in a Windows domain. They will use their domain credentials to log in to your samba server. Then samba will map them to some_share_user.