Thursday, 5 September 2013

Configuring Samba


  1. #yum install samba
  2. #service smb restart
  3. #chkconfig smb on
  4. #vim /etc/samba/smb.conf
    1. Line 57 Ensure foll. is there --->  [global]
    2. Line 74 Put appropriate group name as required. default is workgroup = MYGROUP
      1. eg. workgroup = REDHAT
    3. Last Line : Copy last 7 lines and paste it below that, fill/replace  as per question.
      1. eg share name=song, path=/mp3
        1. [song]
        2. comment=my collection
        3. path=/mp3
        4. public=yes
        5. writable=yes
        6. printable=no
        7. write list=+staff   ---->group name
      2. Then add following so that people can browse it
        1. browseable=yes
  5. #service smb restart
  6. #mkdir /mp3
  7. Then run following on the client side to verify which share name is available against given IP/hostname
    1. #smbclient -L <IP address>
  8. Check the context of the file to be shared
    1. #ls -ldZ /mp3 ----> default context is default_t
  9. Change context of the file to be shared
    1. #chcon -t samba_share_t /mp3
  10. We can verify it
    1. in the file /etc/samba/smb.conf       ---> Line 40
    2. #smbclient //localhost/song -U       ---> U is for anonymous user
  11. If not sharing with public user [#vim /etc/samba/smb.conf]
    1. Remove, public=yes
    2. Or put, public=no
      1. valid user = u1,  u2,  u3
      2. host allow = 192.168.0.
    3. save & quit
  12. Now create samba user
    1. #useradd -s /sbin/nologin u1
    2. #useradd -s /sbin/nologin u2
    3. #useradd -s /sbin/nologin u3
  13. Assign samba password to user u1, u2, u3
    1. #smbpasswd -a u1
    2. #smbpasswd -a u2
    3. #smbpasswd -a u3
  14. #service smb restart
  15. #smbclient -L localhost
  16. #smbclient //localhost/song -U u1
  17. Verification
    1. Now mount it (o=lowercase alphabet o)
    2. #mount -t cifs -o user=u1 localhost:/ /mnt         ----> It will ask password for user u1
    3. #mount -t cifs -o user=u1%123 localhost:/song /mnt      ----> Password for user u1 is mentioned as 123
  18. #df -h

No comments:

Post a Comment