Thursday, December 10, 2009

Enabling Samba on FreeBSD

Enabling Samba on FreeBSD

The following steps can be used to enable Samba on FreeBSD.

Notes:

Related Urls:

Steps for Samba version 3.0.3:

  1. Install Samba from /usr/ports/net/samba-devel:

    # cd /usr/ports/net/samba-devel
    # make install


  2. Enable Samba:

    # echo 'samba_enable="YES"' >> /etc/rc.conf.local


  3. Customize /usr/local/etc/smb.conf:


    • Set the workgroup by change the following:

      workgroup = MYGROUP
      to

      workgroup = workgroup
      This is around line 21.
      If a NT Domain/Workgroup doesn't exist, the workgroup can be set to the DNS domain name.


    • Set the server string by changing the following:

      server string = Samba Server
      to

      server string = hostname
      This is around line 24.


    • Enable password encryption for the [global] share by adding the following:

      # Enable password encryption
         encrypt passwords = yes
      This can be added around line 31.


    • (Optional) Disable printer loading by changing the following:

      load printers = yes
      to

      load printers = no
      This is around line 43.



    • (Optional) Disable the [printers] share by changing the following:

      [printers]
         comment = All Printers
         path = /var/spool/samba
         browseable = no
      # Set public = yes to allow user 'guest account' to print
         guest ok = no
         writable = no
         printable = yes
      to

      ;[printers]
      ;   comment = All Printers
      ;   path = /var/spool/samba
      ;   browseable = no
      # Set public = yes to allow user 'guest account' to print 
      ;   guest ok = no
      ;   writable = no
      ;   printable = yes
      This starts around line 192.


    • (Optional) If CUPS is installed and Samba printing should be enabled change the following:

      ;   printing = bsd
      to

      printing = cups
      This is around line 56.


    • (Optional) Act as a time server:

      # Act as a time server
         time server = yes
      This can be added around line 41.



  4. Valiate smb.conf:

    # /usr/local/bin/testparm -s


  5. Save the default smbpasswd and secrets.tdb:

    # cd /usr/local/private 
    # mv secrets.tdb secrets.tdb.default
    # mv smbpasswd smbpasswd.default
    This may be required only when upgrading from older versions of samba.


  6. Set the samba password for users who need samba access:

    # /usr/local/bin/pdbedit -a username


  7. Start Samba:

    # /usr/local/etc/rc.d/samba.sh start


  8. (Optional) Check to see if samba is running:

    $ ps -auwxx | egrep '[sn]mbd'
    root    909  0.0  0.8  6504 4008  ??  Is   11:29PM   0:00.00 /usr/local/sbin/smbd -D
    root    911  0.0  0.4  3488 2048  ??  Ss   11:29PM   0:00.00 /usr/local/sbin/nmbd -D


  9. (Optional) Test samba using smbclient:

    $ /usr/local/bin/smbclient -U username \\\\localhost\\username
    or

    $ /usr/local/bin/smbclient -U username //localhost/username


Steps for Samba version 3.0.0:

  1. Install Samba from /usr/ports:

    # cd cd /usr/ports/net/samba-devel
    # make install


  2. Enable Samba:

    # cd /usr/local/etc/rc.d
    # ln -s samba.sh.sample samba.sh


  3. Customize /usr/local/etc/smb.conf:


    • Set the server string by changing the following:

      server string = Samba Server
      to

      server string = hostname
      This is around line 21.


    • Modify logging (samba creates two log files per host that connects, so a separate samba log directory is useful) by changing the following:

      log file = /var/log/log.%m
      to

      log file = /var/log/samba/log.%m
      This is around line 54.


    • Enable password encryption by changing the following:

      ;  encrypt passwords = yes
      to

      encrypt passwords = yes
      This is around line 67.


    • Enable password synchronization by adding the following to the [global] share:

      # Enable unix password synchronization
        unix password sync = yes
        passwd program = /usr/bin/passwd %u
      This can be added around line 69.


    • (Optional) Disable printer loading by changing the following:

      load printers = yes
      to

      load printers = no
      This is around line 32.



    • (Optional) Disable the [printers] share by changing the following:

      [printers]
         comment = All Printers
         path = /var/spool/samba
         browseable = no
      # Set public = yes to allow user 'guest account' to print
         guest ok = no
         writeable = no
         printable = yes
      to

      ;[printers]
      ;   comment = All Printers
      ;   path = /var/spool/samba
      ;   browseable = no
      ;# Set public = yes to allow user 'guest account' to print
      ;   guest ok = no
      ;   writeable = no
      ;   printable = yes
      This starts around line 170.


    • (Optional) If CUPS is installed and Samba printing should be enabled change the following:

      ;   printing = bsd
      to

      printing = cups
      This is around line 45.



  4. Create the samba log file directory:

    # mkdir -p /var/log/samba


  5. Set the samba password for users who need samba access:

    # /usr/local/bin/pdbedit -a username


  6. Start Samba:

    # /usr/local/etc/rc.d/samba.sh start


  7. (Optional) Check to see if samba is running:

    $ ps -auwxx | egrep '[sn]mbd'
    root    909  0.0  0.8  6504 4008  ??  Is   11:29PM   0:00.00 /usr/local/sbin/smbd -D
    root    911  0.0  0.4  3488 2048  ??  Ss   11:29PM   0:00.00 /usr/local/sbin/nmbd -D


  8. (Optional) Test samba using smbclient:

    $ /usr/local/bin/smbclient \\\\localhost\\username
    or

    $ /usr/local/bin/smbclient //localhost/username

No comments: