Manipulating Samba User Database with pdbedit (with examples)
- Linux
- November 5, 2023
1. Listing all Samba users with verbose settings
To list all Samba users along with their settings, you can use the --list
flag along with the --verbose
flag in the pdbedit
command. The --list
flag specifies that we want to list all users, while the --verbose
flag provides detailed information about each user’s settings.
sudo pdbedit --list --verbose
This use case is useful when you need to check the current Samba users on your system and view their specific settings. The verbose output includes information such as the user’s username, UID, GID, home directory, shell, and more.
Example Output:
Unix Username: user1
NT Username: -
Account Flags: [U
User SID: S-1-5-21-1234567890-1234567890-1234567890-1001
Primary Group SID: S-1-5-21-1234567890-1234567890-1234567890-1001
2. Adding an existing Unix user to Samba
To add an existing Unix user to Samba, you can use the --user
flag followed by the username. This will prompt you to set a password for the Samba user.
sudo pdbedit --user username --create
This use case is helpful when you want to grant an existing Unix user access to Samba services. By adding the user to Samba, they will be able to authenticate and access Samba shares.
Example Output:
New SMB password:
Retype new SMB password:
Added user username.
3. Removing a Samba user
To remove a specific Samba user from the user database, you can use the --user
flag followed by the username and the --delete
flag.
sudo pdbedit --user username --delete
This use case is handy when you want to revoke access for a particular user from Samba. It will remove their credentials and settings from the Samba user database.
Example Output:
Deleting user username.
4. Resetting a Samba user’s failed password counter
If a Samba user has entered an incorrect password multiple times and gets locked out, you can reset their failed password counter. This can be done using the --user
flag followed by the username and the --bad-password-count-reset
flag.
sudo pdbedit --user username --bad-password-count-reset
This use case is valuable when you want to give a Samba user another chance to authenticate without getting locked out due to previous failed attempts.
Example Output:
Resetting failed login count for user username.