Showing posts with label samba. Show all posts
Showing posts with label samba. Show all posts

Tuesday, February 7, 2012

CIFS Automount in Linux

Assuming that you have autofs installed and running, add an appropriate entry in /etc/auto.master like so:
/mnt/smb /etc/auto.smbfs --timeout=120

Inside /etc/auto.smbfs (make it executable (chmod +x /etc/auto.smbfs)):
* -fstype=autofs,-Dhost=& file:/etc/auto.smb.sub

And inside /etc/auto.smb.sub, you have a few choices:

If you want to set the uid and gid of the credentials accessing the CIFS share (this defaults to read only):

* -fstype=cifs,credentials=/etc/cifssecret.txt,uid=101,gid=101 ://${host}/& 

otherwise:

* -fstype=cifs,credentials=/etc/cifssecret.txt,rw ://${host}/&
This will let you connect to any samba server or windows server on the mount point
/mnt/smb/servername/share_name




Of course, if you want to hard code the CIFS server name and share:

* -fstype=cifs,credentials=/etc/cifssecret.txt,rw ://mycifsserver/the_share_you_want
 
Inside /etc/cifssecret.txt:

username=yoursambaOrCIFSuser
password=yourcifspassword

chown root /etc/cifssecret.txt
chmod 400 /etc/cifssecret.txt

restart autofs:

sudo /sbin/service autofs restart

And do a listing of some server on that share:

ls /mnt/smb/myWindowsServer/share1


Thursday, September 30, 2010

CentOS 5.5, Samba/Winbind, Windows 2008R2 Active Directory

In order to facilitate client backups, I set up samba on CentOS on a Windows 2008R2 based domain. I created an empty directory, /etc/skel2, as I was not planning on letting users log in via ssh or the console.

 Unfortunately, the samba 3.0.x line wouldn't work correctly. I could join the domain, but not connect to shares. Samba logged the following message every connection attempt:


  read_data: read failure for 4 bytes to client 192.168.70.23. Error = Connection reset by peer

I upgraded to the Samba3 package with yum (Samba 3.3.x) and rejoined. I added a pam.d entry in the samba config:

 session required pam_mkhomedir.so skel=/etc/skel2 umask=0077


( I don't want users to see each other's directories. I did not modify system-auth, as I did not want the users to log in with anything but samba.)

And added this to smb.conf:


  winbind separator = \
  # use uids from 10000 to 20000 for domain users
  idmap uid = 10000-20000
 # use gids from 10000 to 20000 for domain groups
 idmap gid = 10000-20000
 # allow enumeration of winbind users and groups
 winbind enum users = yes
 winbind enum groups = yes
 winbind use default domain = yes
 # give winbind users a real shell (only needed if they have telnet access)
 template homedir = /data/clientdata/backups/%D/%U
 template shell = /bin/bash

 obey pam restrictions = yes

An important note, the samba3 rpm separates the smbd and nmbd init scripts, so you'll need to do a separate "chkconfig nmb on."