Samba stores its encrypted passwords in a file called
smbpasswd, which by default resides in the
/usr/local/samba/private directory. The
smbpasswd file should be guarded as closely as the
passwd file; it should be placed in a directory to which only the root user has read/write access. All other users should not be able to read from the directory at all. In addition, the file should have all access closed off to all users except for root.
Before you can use encrypted passwords, you will need to create an entry for each Unix user in the
smbpasswd file. The structure of the file is somewhat similar to a Unix
passwd file, but has different fields.
Figure 6.3 illustrates the layout of the
smbpasswd file; the entry shown is actually one line in the file.
Here is a breakdown of the individual fields:
-
Username
-
This is the username of the account. It is taken directly from the system password file.
-
UID
-
This is the user ID of the account. Like the username, it is taken directly from the system password file and must match the user it represents there.
-
LAN Manager Password Hash
-
This is a 32-bit hexadecimal sequence that represents the password Windows 95 and 98 clients will use. It is derived by encrypting the string
KGS!@#$%
with a 56-bit DES algorithm using the user's password (forced to 14 bytes and converted to capital letters) twice repeated as the key. If there is currently no password for this user, the first 11 characters of the hash will consist of the sequence
NO
PASSWORD
followed by
X
characters for the remainder. Anyone can access the share with no password. On the other hand, if the password has been disabled, it will consist of 32
X
characters. Samba will not grant access to a user without a password unless the
null
passwords
option has been set.
-
NT Password Hash
-
This is a 32-bit hexadecimal sequence that represents the password Windows NT clients will use. It is derived by hashing the user's password (represented as a 16-bit little-endian Unicode sequence) with an MD4 hash. The password is not converted to uppercase letters first.
-
Account Flags
-
This field consists of 11 characters between two braces ( [ ] ). Any of the following characters can appear in any order; the remaining characters should be spaces:
U
This account is a standard user account.
D
This account is currently disabled and Samba should not allow any logins.
N
This account has no password associated with it.
W
This is a workstation trust account that can be used to configure Samba as a primary domain controller (PDC) when allowing Windows NT machines to join its domain.
-
Last Change Time
-
This code consists of the characters
LCT-
followed by a hexidecimal representation of the amount of seconds since the epoch (midnight on January 1, 1970) that the entry was last changed.