Thursday, March 27, 2014

Samba on RHEL-6 with Windows 7


[user1@rhel-6 ~]$ su - root
Password:
[root@rhel-6 ~]# service smb status
smbd is stopped

[root@rhel-6 ~]# service smb start
Starting SMB services:
                                   [  OK  ]
[root@rhel-6 ~]# service smb status
smbd (pid  62320) is running...

[root@rhel-6 ~]# ps -aef | grep smb
root     62320     1  1 16:07 ?        00:00:00 smbd
root     62323 62320  3 16:07 ?        00:00:00 smbd
root     62334 62284  0 16:07 pts/1    00:00:00 grep smb

[root@rhel-6 ~]# cp -p /etc/samba/smb.conf /etc/samba/smb.conf.orig

[root@rhel-6 ~]# ls -la /etc/samba/smb.*
-rw-r--r-- 1 root root 11464 Jan 23  2013 /etc/samba/smb.conf
-rw-r--r-- 1 root root 11464 Aug 14  2013 /etc/samba/smb.conf.bak
-rw-r--r-- 1 root root 11464 Jan 23  2013 /etc/samba/smb.conf.orig
-rw-r--r-- 1 root root 10031 Aug 13  2013 /etc/samba/smb.conf.rpmsave

[root@rhel-6 ~]# vi /etc/samba/smb.conf

In the [global] section set the workgroup parameter:
 workgroup = RA-DEMO
 add the following to the end of the file then save it:
[samba-demo]
 comment = RHEL6-Windows Demo Share
 path=/samba-demo
 writeable = yes
 browseable = yes
 valid users = samba-user


  groupadd -g 1234 samba-users
  adduser -d /samba-demo -m -u 1234 -g 1234 -c "Samba demo user accnt" \
  adduser -d /samba-demo -m -u 1234 -g 1234 -c "Samba demo user accnt" samba-user
  ls -ld /samba-demo
  echo "This file was placed in the /samba-demo file share area on the RHEL6 server. > /samba-demo/This_is_the_RHEL6_server
  echo "This file was placed in the /samba-demo file share area on the RHEL6 server" > /samba-demo/This_is_the_RHEL6_server
  chown samba-user:samba-users /samba-demo/This_is_the_RHEL6_server
  ls -ld /samba-demo
  ls -l /samba-demo

[root@rhel-6 ~]# groupadd -g 1234 samba-users

[root@rhel-6 ~]# adduser -d /samba-demo -m -u 1234 -g 1234 -c "Samba demo user accnt" samba-user

[root@rhel-6 ~]# ls -ld /samba-demo
drwx------ 4 samba-user samba-users 4096 Mar 25 16:10 /samba-demo

[root@rhel-6 ~]# echo .This file was placed in the /samba-demo file share area on the
.This file was placed in the /samba-demo file share area on the

[root@rhel-6 ~]# echo "This file was placed in the /samba-demo file share area on the RHEL6 server" > /samba-demo/This_is_the_RHEL6_server

[root@rhel-6 ~]# chown samba-user:samba-users /samba-demo/This_is_the_RHEL6_server

[root@rhel-6 ~]# ls -ld /samba-demo
drwx------ 4 samba-user samba-users 4096 Mar 25 16:11 /samba-demo

[root@rhel-6 ~]# ls -l /samba-demo
total 4
-rw-r--r-- 1 samba-user samba-users 76 Mar 25 16:11 This_is_the_RHEL6_server

[root@rhel-6 ~]# smbpasswd -a samba-user
New SMB password:
Retype new SMB password:
Added user samba-user.

[root@rhel-6 ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[samba-demo]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
        workgroup = RA-DEMO
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        idmap config * : backend = tdb
        cups options = raw

[homes]
        comment = Home Directories
        read only = No
        browseable = No

[printers]
        comment = All Printers
        path = /var/spool/samba
        printable = Yes
        print ok = Yes
        browseable = No

[samba-demo]
        comment = RHEL6-Windows Demo Share
        path = /samba-demo
        valid users = samba-user
        read only = No

[root@rhel-6 ~]# service smb restart
Shutting down SMB services:                                [  OK  ]
Starting SMB services:                                     [  OK  ]
[root@rhel-6 ~]# service smb status
smbd (pid  62398) is running...
[root@rhel-6 ~]# chkconfig smb on
[root@rhel-6 ~]# chkconfig --list smb
smb             0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@rhel-6 ~]# smbclient -L RHEL6-srv -U samba-user
Enter samba-user's password:
Connection to RHEL6-srv failed (Error NT_STATUS_UNSUCCESSFUL)
[root@rhel-6 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:9E:C1
          inet addr:142.88.100.106  Bcast:144.77.109.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0d:9ec1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4375060 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1329280 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1372746393 (1.2 GiB)  TX bytes:1005914980 (959.3 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)

[root@rhel-6 ~]# smbclient -L 142.88.100.106 -U samba-user
Enter samba-user's password:
Domain=[RA-DEMO] OS=[Unix] Server=[Samba 4.0.0rc4]

        Sharename       Type      Comment
        ---------       ----      -------
        samba-demo      Disk      RHEL6-Windows Demo Share
        IPC$            IPC       IPC Service (Samba Server Version 4.0.0rc4)
        Microsoft_XPS_Document_Writer_(from_XP0007)_in_session_225_(redirected_1):27 Printer   PDFCreator (redirected 1)
        Microsoft_XPS_Document_Writer:3 Printer   Microsoft XPS Document Writer
        Microsoft_XPS_Document_Writer_(from_BOA0007D)_in_session_6_(redirected_1):24 Printer   HP Deskjet F4400 series (from W0_Nm0Qhounsvj4sran-) in session 9 (redirected 1)
        Fax:4           Printer   Fax
        HP_LaserJet_P4014.P4015_PCL6:8 Printer   HP LaserJet P4014/P4015 PCL6
        PDFCreator_(redirected_1):14 Printer   Microsoft XPS Document Writer (from PHNT-NAN227) in session 25 (redirected 1)
        Microsoft_XPS_Document_Writer_(from_WI_TjLWE1WS44HyRnVxQ)_in_session_10_(redirected_1):26 Printer   RightFax Fax Printer (redirected 1)
        Microsoft_XPS_Document_Writer_from_rgraber_(redirected_1):28 Printer   sutterec_gbutler (redirected 1)
        VMP001P2\Laser396:5 Printer   \\VMP001P2\Laser396
        Client.NEE-E0391945$Microsoft_XPS_Document_Writer_(redirected_1):10 Printer   Nitro PDF Creator (Pro 8) (from W0_Nm0Qhounsvj4sran-) in session 9 (redirected 1)
        Microsoft_XPS_Document_Writer_(redirected_1):11 Printer   Client/US-AC63906#/Microsoft XPS Document Writer (redirected 1)
        RightFax_Fax_Printer:2 Printer   RightFax Fax Printer
        Foxit_Reader_PDF_Printer:7 Printer   Foxit Reader PDF Printer
        Microsoft_XPS_Document_Writer_(from_WI_Y6oeiaFFxtABLEAHd)_in_session_1_(redirected_1):20 Printer   RightFax Fax Printer (redirected 1)
        Microsoft_XPS_Document_Writer_(from_SAP_ALL-D046154)_in_session_30_(redirected_1):25 Printer   Microsoft XPS Document Writer (redirected 1)
        Microsoft_XPS_Document_Writer_(from_TXUCORP-JYIB)_in_session_6_(redirected_1):16 Printer   Microsoft XPS Document Writer (from TXUCORP-JYIB) in session 6 (redirected 1)
        Send_To_OneNote_2010_(redirected_1):13 Printer   Microsoft XPS Document Writer (from JNBWKS77) in session 9 (redirected 1)
        Microsoft_XPS_Document_Writer_(from_WI_s67pKbyniVmHYkqSX)_in_session_5_(redirected_1):19 Printer   Microsoft XPS Document Writer (from W0_Nm0Qhounsvj4sran-) in session 9 (redirected 1)
        Microsoft_XPS_Document_Writer_(from_WI_mvaQVbkPEQoCAn_VP)_in_session_2_(redirected_1):18 Printer   Microsoft XPS Document Writer [ICA-tcp#9445] (redirected 1)
        Microsoft_XPS_Document_Writer_from_cfritz_(redirected_1):23 Printer   Send To OneNote 2010 (redirected 1)
        RightFax_Fax_Printer_(redirected_1):12 Printer   Microsoft XPS Document Writer (from CZC81527W0) in session 19 (redirected 1)
        VMP001P2\Laser369_Color:6 Printer   \\VMP001P2\Laser369_Color
        Microsoft_XPS_Document_Writer_from_bkuhns_(redirected_1):22 Printer   Microsoft XPS Document Writer (redirected 1)
        Send_To_OneNote_2010:1 Printer   Send To OneNote 2010
        Microsoft_XPS_Document_Writer_(from_WRG239113)_in_session_4_(redirected_1):21 Printer   PDFCreator (redirected 1)
        Microsoft_XPS_Document_Writer_(from_W0_R_T0OwPjsoCfOio4J)_in_session_8_(redirected_1):29 Printer   Send To OneNote 2010 (redirected 1)
        Microsoft_XPS_Document_Writer_(ICA-tcp$9445)_(redirected_1):15 Printer   Microsoft XPS Document Writer (from TXUCORP-CFK8) in session 8 (redirected 1)
        VMP001P2\Laser356:9 Printer   \\VMP001P2\Laser356
        Microsoft_XPS_Document_Writer_(from_UNN-HSHS3)_in_session_10_(redirected_1):17 Printer   Microsoft XPS Document Writer (from WRG239113) in session 4 (redirected 1)
        samba-user      Disk      Home Directories
Domain=[RA-DEMO] OS=[Unix] Server=[Samba 4.0.0rc4]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------
[root@rhel-6 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:0D:9E:C1
          inet addr:142.88.100.106  Bcast:144.77.109.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0d:9ec1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4375461 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1329329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1372812844 (1.2 GiB)  TX bytes:1005924674 (959.3 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:57 errors:0 dropped:0 overruns:0 frame:0
          TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:14929 (14.5 KiB)  TX bytes:14929 (14.5 KiB)


[root@rhel-6 ~]# smbclient -L //142.88.100.106/samba-demo -U samba-user
Enter samba-user's password:
Domain=[RA-DEMO] OS=[Unix] Server=[Samba 4.0.0rc4]

        Sharename       Type      Comment
        ---------       ----      -------
        samba-demo      Disk      RHEL6-Windows Demo Share
        IPC$            IPC       IPC Service (Samba Server Version 4.0.0rc4)
        Microsoft_XPS_Document_Writer_(from_XP0007)_in_session_225_(redirected_1):27 Printer   PDFCreator (redirected 1)
        Microsoft_XPS_Document_Writer:3 Printer   Microsoft XPS Document Writer
        Microsoft_XPS_Document_Writer_(from_BOA0007D)_in_session_6_(redirected_1):24 Printer   HP Deskjet F4400 series (from W0_Nm0Qhounsvj4sran-) in session 9 (redirected 1)
        Fax:4           Printer   Fax
        HP_LaserJet_P4014.P4015_PCL6:8 Printer   HP LaserJet P4014/P4015 PCL6
        PDFCreator_(redirected_1):14 Printer   Microsoft XPS Document Writer (from PHNT-NAN227) in session 25 (redirected 1)
        Microsoft_XPS_Document_Writer_(from_WI_TjLWE1WS44HyRnVxQ)_in_session_10_(redirected_1):26 Printer   RightFax Fax Printer (redirected 1)
        Microsoft_XPS_Document_Writer_from_rgraber_(redirected_1):28 Printer   sutterec_gbutler (redirected 1)
        VMP001P2\Laser396:5 Printer   \\VMP001P2\Laser396
        Client.NEE-E0391945$Microsoft_XPS_Document_Writer_(redirected_1):10 Printer   Nitro PDF Creator (Pro 8) (from W0_Nm0Qhounsvj4sran-) in session 9 (redirected 1)
        Microsoft_XPS_Document_Writer_(redirected_1):11 Printer   Client/US-AC63906#/Microsoft XPS Document Writer (redirected 1)
        RightFax_Fax_Printer:2 Printer   RightFax Fax Printer
        Foxit_Reader_PDF_Printer:7 Printer   Foxit Reader PDF Printer
        Microsoft_XPS_Document_Writer_(from_WI_Y6oeiaFFxtABLEAHd)_in_session_1_(redirected_1):20 Printer   RightFax Fax Printer (redirected 1)
        Microsoft_XPS_Document_Writer_(from_SAP_ALL-D046154)_in_session_30_(redirected_1):25 Printer   Microsoft XPS Document Writer (redirected 1)
        Microsoft_XPS_Document_Writer_(from_TXUCORP-JYIB)_in_session_6_(redirected_1):16 Printer   Microsoft XPS Document Writer (from TXUCORP-JYIB) in session 6 (redirected 1)
        Send_To_OneNote_2010_(redirected_1):13 Printer   Microsoft XPS Document Writer (from JNBWKS77) in session 9 (redirected 1)
        Microsoft_XPS_Document_Writer_(from_WI_s67pKbyniVmHYkqSX)_in_session_5_(redirected_1):19 Printer   Microsoft XPS Document Writer (from W0_Nm0Qhounsvj4sran-) in session 9 (redirected 1)
        Microsoft_XPS_Document_Writer_(from_WI_mvaQVbkPEQoCAn_VP)_in_session_2_(redirected_1):18 Printer   Microsoft XPS Document Writer [ICA-tcp#9445] (redirected 1)
        Microsoft_XPS_Document_Writer_from_cfritz_(redirected_1):23 Printer   Send To OneNote 2010 (redirected 1)
        RightFax_Fax_Printer_(redirected_1):12 Printer   Microsoft XPS Document Writer (from CZC81527W0) in session 19 (redirected 1)
        VMP001P2\Laser369_Color:6 Printer   \\VMP001P2\Laser369_Color
        Microsoft_XPS_Document_Writer_from_bkuhns_(redirected_1):22 Printer   Microsoft XPS Document Writer (redirected 1)
        Send_To_OneNote_2010:1 Printer   Send To OneNote 2010
        Microsoft_XPS_Document_Writer_(from_WRG239113)_in_session_4_(redirected_1):21 Printer   PDFCreator (redirected 1)
        Microsoft_XPS_Document_Writer_(from_W0_R_T0OwPjsoCfOio4J)_in_session_8_(redirected_1):29 Printer   Send To OneNote 2010 (redirected 1)
        Microsoft_XPS_Document_Writer_(ICA-tcp$9445)_(redirected_1):15 Printer   Microsoft XPS Document Writer (from TXUCORP-CFK8) in session 8 (redirected 1)
        VMP001P2\Laser356:9 Printer   \\VMP001P2\Laser356
        Microsoft_XPS_Document_Writer_(from_UNN-HSHS3)_in_session_10_(redirected_1):17 Printer   Microsoft XPS Document Writer (from WRG239113) in session 4 (redirected 1)
        samba-user      Disk      Home Directories
Domain=[RA-DEMO] OS=[Unix] Server=[Samba 4.0.0rc4]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------

Lastly to access from Windows 7 i.e. to map:

Apply the following rules to the /etc/sysconfig/iptables firewall

restart the iptables

service iptables restart

-A INPUT -p tcp -m state --state NEW -m tcp --dport 137 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 138 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 139 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT


[root@rhel-6 ~]# smbclient  //142.88.100.106/samba-demo -U samba-user
Enter samba-user's password:
Domain=[RA-DEMO] OS=[Unix] Server=[Samba 4.0.0rc4]
smb: \> ls
  .                                   D        0  Tue Mar 25 16:11:28 2014
  ..                                 DR        0  Tue Mar 25 16:10:09 2014
  This_is_the_RHEL6_server            A       85  Tue Mar 25 16:35:08 2014
  .mozilla                           DH        0  Mon May 20 05:32:55 2013
  .bash_profile                       H      176  Wed Aug 29 04:19:40 2012
  .gnome2                            DH        0  Wed Jul 14 08:55:40 2010
  .bashrc                             H      124  Wed Aug 29 04:19:40 2012
  .bash_logout                        H       18  Wed Aug 29 04:19:40 2012
  Axway_-_Axway_SecureTransport on vmware.pdf      A    85952  Thu Jul 18 09:42:30 2013

                52008 blocks of size 524288. 17385 blocks available
smb: \>

Now map the drive for samba share: see the screen shot: