Samba – How to recreate samba secrets.tdb file

centos6samba

While trying to setup samba on an NFS server I deleted (don't ask) the /var/lib/samba/ contents and now when I try to start samba, this messages appears :

[2012/07/06 08:19:07.528973,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/private/secrets.tdb
[2012/07/06 08:19:07.689735,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/private/secrets.tdb
[2012/07/06 08:19:07.690078,  0] smbd/server.c:1240(main)
  ERROR: smbd can not open secrets.tdb

So how do I recreate the secrets.tdb file and the rest of the needed files if any ?

Best Answer

Use smbpasswd which will create the file if it doesn't exist when you add a new user

ls -l /var/lib/samba/private/secrets.tdb
ls: cannot access /var/lib/samba/private/secrets.tdb: No such file or directory

smbbpasswd iain
New SMB password:
Retype new SMB password:

ls -l /var/lib/samba/private/secrets.tdb
-rw-------. 1 root root 45056 Jul  6 07:54 /var/lib/samba/private/secrets.tdb