Samba is the server used to share files from a Linux server to the rest of the windows clients in an office,
it is an easy to use server with simple defaults that will make the integration easy into any domain,
you can find on the samba main site some configurations samples and newer smb.conf samples to help ease the server into the domain.
But the harder part after setting the server is debugging problems with it,
like a user permission problem – can the user authenticate to the Microsoft domain server?
maybe he has a password problem? maybe he doesn’t have permission to access the share?
Setting up samba logging:
For starters you will find all the config files are at /etc/smb
the main config file is smb.conf,
other important files are smbusers and smbpasswd,
smbusers is a mapping file, to mask windows user as a linux user for access.
Now first thing to do when debugging is to setup the logging well,
so these are good log settings in the /etc/samba/smb.conf for debugging of the samba service:
log file = /var/log/samba/%m.log
syslog = 0
log level = 3 passdb:0 auth:0 winbind:0 vfs:0
vfs objects = full_audit
- log file = /var/log/samba/%m.log the %m is substituted for the machine name.
- syslog = 0 0 means only LOG_ERR will be sent to the syslog,
If you want more info to be sent there change it to 3
- log level = 3 passdb:0 auth:0 winbind:0 vfs:0 gives better control over which options to log
- vfs objects = full_audit this allows for full details on which files are accessed by whom.
With this configuration all the machines log files will be found under /var/log/samba/*.log
for a sample, if you been trying to connect to the samba server from a machine named “boo1″
you should see in the log folder: /var/log/samba/boo1.log
You can search inside the folder by using “ls –latr” to find the newest files,
which will mean the windows clients that have been trying to connect to te samba server.
And “tail -100 machine_name.log” to view the errors you got if you couldn’t access the share.
Real life Debug sample:
from the file temp1.log:
user ‘temp1′ (from session setup) not permitted to access this share (share2)
This error means to that your user is known as temp1,
and temp1 doesn’t have permission to access the share “share2”
in which case you need to open the smb.conf and setup the permissions
for the user on this share to allow him access.
Inside smbusers you can map windows users to a specific unix user with this syntax:
unix_user = MY_DOMAIN\windows_user1 MY_DOMAIN\windows_user2 MY_DOMAIN\windows_user3
And then allow access to shares in the config by using the unix name:
valid users = unix_user
Checking access to the server and listing shares on it from commend line:
smbclient -L //server -U windows_user
You will be prompt for password, and if the settings are good, you will receive the shares listing from the server.
Connecting to a share on the server:
smbclient //server/share -U windows_user
after answering the password you get a command line much like ftp:
smbclient //server/share -U builder
Domain=[MY_DOMAIN] OS=[Unix] Server=[Samba 3.0.33-3.7.el5_3.1]
mounting windows share on linux from fstab:
This will allow for automatic mount in case of server reboot:
\\server\share /unix_location smbfs credentials=/etc/samba.sharepasswd,uid=unix_user,gid=unix_group,ip=192.168.0.1,lfs 0 0
Contents of /etc/samba/.sharepasswd should be windows user and password to connect to the share:
Getting info from a windows domain controller for samba debugging:
To list all the windows domain users from linux command line:
net rpc username -S icq-mdc1
replace “username” with a valid windows user name, to list all the users in the server,
you will need to know the user password as well.
This command can list the user groups from the domain controller:
net rpc user INFO username -S domain-server-name
replace “username” with a valid windows user name.