Search This Blog

Showing posts with label SWAT Web interface for SAMBA. Show all posts
Showing posts with label SWAT Web interface for SAMBA. Show all posts

Wednesday, December 7, 2011

The [netlogon] and [profiles] Share Sections (SAMBA, SWAT) - PART7


The [netlogon] share section contains scripts that the windows clients may use when they log into the domain. The [profiles] share section stores settings related to the look and feel of windows so that the user has the same settings no matter which Windows PC is logged into. The [profiles] share section stores things such as favorites and desktop icons.
Your smb.conf file should look like this when you're finished:
[netlogon]
       path = /home/samba/netlogon
       guest ok = Yes

[profiles]
       path = /home/samba/profiles
       read only = No
       create mask = 0600
       directory mask = 0700
Here's how to do it.
  1. Click the Shares button.
  2. Create a [netlogon] share.
  3. Modify the path and guest ok settings.
  4. Click on the Commit Changes button.
  5. Create a [profiles] share section.
  6. Modify the path, mask and read only settings. The mask settings allow only the owner of the netlogon subdirectory to be able to modify its contents.
  7. Click on the Commit Changes button.
Remember to create these share directories from the command line afterwards.
[root@bigboy tmp]# mkdir -p /home/samba/netlogon
[root@bigboy tmp]# mkdir -p /home/samba/profile
[root@bigboy tmp]# chmod -R 0755 /home/samba

Tuesday, December 6, 2011

Using The SWAT Wizard (SAMBA) - PART6


The SWAT utility has a Wizard button that can be used to configure your server as a PDC quickly. However the defaults may not be to your liking, for example, the default domain is MYGROUP and some of the [global] parameters mentioned previously will be set to auto.

The [homes] Section

Part of the process of adding a user to a Samba domain requires you to create a Linux user on the Samba PDC itself. When you log into the Samba PDC, you'll see a new drive, usually named Z:, added to your PC. This is actually a virtual drive that maps to the corresponding Linux users' login directories on the Linux PDC.
Samba considers all directories to be shares that can be configured with varying degrees of security. The [homes] section governs how Samba handles default login directories.
Table 10-3 explains the minimum settings you need to create a functional [Homes] section.

Table 10-3 : smb.conf Minimum Settings, "Home" Section

ParameterValueDescription
browseableNoDoesn't allow others to browse the contents of the directory
read onlyNoAllows the samba user to also write to their Samba Linux directory
create mask0664Makes new files created by the user to have "644" permissions. You want to change this to "0600" so that only the login user has access to files.
directory mask0775Makes new sub-directories created by the user to have "775" permissions. You want to change this to "0700" so that only the login user has access to directories.
Here's how to set the values using SWAT:
  1. Click on the SWAT shares button to proceed to where shared directories are configured.
  2. Click the Advanced button to see all the options.
  3. Choose the Homes share.
  4. Make your changes and click on the Commit Changes button when finished.
  5. Your smb.conf file should resemble this when finished. You can view the contents of the configuration file by logging in to the samba server via a command prompt and using the cat /etc/samba/smb.conf to verify your changes as you do them.
[homes]
  read only = No
  browseable = No
  create mask = 0644
  directory mask = 0755

Monday, December 5, 2011

How To Make SWAT Changes Immediate (SAMBA) - PART5


SWAT immediately changes the functioning of Samba whenever you commit your changes through the web GUI.

Creating A Starter Configuration

I'll now illustrate how to configure a Samba server to be the PDC for a small network is by using SWAT. You'll need to edit the various sections of the smb.conf file, so I'll walk you through what you'll find in each.

The [Global] Section

The [global] section governs the general Samba settings. Table 10-2 explains the parameters you need to set in order to create a PDC.

Table 10-2 : smb.conf Minimum Settings, "Global" Section

ParametervalueDescription
domain logonsYesTells Samba to become the PDC
preferred masterYesMakes the PDC act as the central store for the names of all windows clients, servers and printers on the network. Very helpful when you need to "browse" your local network for resources. Also known as a local master browser.
domain masterYesTells Samba to become the master browser across multiple networks all over the domain. The local master browsers register themselves with the domain master to learn about resources on other networks.
os level65Sets the priority the Samba server should use when negotiating to become the PDC with other Windows servers. A value of 65 will usually make the Samba server win.
wins supportYesAllows the Samba server to provide name services for the network. In other words keeps track of the IP addresses of all the domain's servers and clients.
time serverYesLets the samba server provide time updates for the domain's clients.
workgroup"homenet"The name of the Windows domain we'll create. The name you select is your choice. I've decided to use "homenet".
securityuserMake domain logins query the Samba password database located on the samba server itself.
smb passwd file/etc/samba/smbpasswdIt is useful to specify the name and location of the Samba password file. This helps to make Samba version upgrades where the default locations may change.
private dir/etc/sambaSpecifies default directory for some supporting temporary files. As with the password file, it is a good practice to specify this value.
Here's how to set the values using SWAT.
  1. Log into SWAT and click on the [global] section.
  2. Click the Advanced button to see all the options.
  3. Make your changes and click on the Commit Changes button when finished.
  4. Your smb.conf file should resemble the example below when you're finished. You can view the contents of the configuration file by logging in to the samba server via a command prompt and using the cat /etc/samba/smb.conf to verify your changes as you do them.
[global]

       workgroup = HOMENET
       time server = Yes
       domain logons = Yes
       os level = 65
       preferred master = Yes
       domain master = Yes
       smb passwd file = /etc/samba/smbpasswd
       private dir = /etc/samba
Note: security = user and WINS support = yes are default settings for Samba and they may not show up in your smb.conf file, even though you may see them in SWAT.

Sunday, December 4, 2011

Encrypting SWAT (SAMBA Configuration) - PART4


By default SWAT is configured via an unencrypted web link using the Linux root account. When running SWAT in the unsecured mode above you should take the added precaution of using it from the Linux console whenever possible.
You can configure SWAT to work only with securely encrypted HTTP (HTTPS) versus the regular HTTP method shown above. Here is how it's done. (Please refer to the VPN section of Appendix I, "Miscellaneous Linux Topics," for more details on encryption methods.)

Create An stunnel User

You can create a stunnel user via the useradd command:
[root@bigboy tmp]# useradd stunnel

Create The Certificates

From the /etc/stunnel directory and create the encryption key certificate using the make command. Use all the defaults when prompted, but make sure you use the server's IP address when prompted for your server's Common Name or hostname.
[root@bigboy tmp]# cd /etc/stunnel
[root@bigboy stunnel]# make stunnel.pem
...
Common Name (eg, your name or your server's hostname) []:  172.16.1.200
...
[root@bigboy stunnel]#
Note: The resulting certificate has only a 365 day lifetime. Remember to repeat this process next year.

Modify Certificate File Permissions

The certificate needs to only be read by root and the stunnel user. Use the chmod and chgrp commands to do this.
[root@bigboy stunnel]# chmod 640 stunnel.pem
[root@bigboy stunnel]# chgrp stunnel stunnel.pem

[root@bigboy stunnel]# ll
-rw-r-----  1 root stunnel   1991 Jul 31 21:50 stunnel.pem
[root@bigboy stunnel]#

Create An /etc/stunnel/stunnel.conf Configuration File

You can configure the stunnel application to:
  • Intercept encrypted SSL traffic received on any TCP port
  • Decrypt this traffic
  • Funnel the unencrypted data to any application listening on another port.
For example, you can configure the /etc/stunnel/stunnel.conf file to intercept SSL traffic on the SWAT port 901 and funnel it decrypted to a SWAT daemon running on port 902. Here's how:
# Configure stunnel to run as user "stunnel" placing temporary 
# files in the /home/stunnel/ directory
chroot  = /home/stunnel/
pid     = /stunnel.pid
setuid  = stunnel
setgid  = stunnel
 
# Log all stunnel messages to /var/log/messages 
debug   = 7
output  = /var/log/messages
 
# Define where the SSL certificates can be found.
client  = no
cert    = /etc/stunnel/stunnel.pem
key     = /etc/stunnel/stunnel.pem

# Accept SSL connections on port 901 and funnel it to
# port 902 for swat. 
[swat]
accept   = 901
connect  = 902

Create A New /etc/xinetd.d File For Secure SWAT

To start, copy the swat file and name it swat-stunnel. We then configure the new file to be enabled, listening on port 902 and accepting connections only from localhost. We also make sure that the service is set to swat-stunnel.
[root@bigboy certs]# cd /etc/xinetd.d
[root@bigboy xinetd.d]# cp swat swat-stunnel
Your new swat-stunnel file should look like this:
service swat-stunnel
{
       port            = 902
       socket_type     = stream
       wait            = no
       only_from       = 127.0.0.1
       user            = root
       server          = /usr/sbin/swat
       log_on_failure  += USERID
       disable         = no
       bind            = 127.0.0.1
}

Disable SWAT in the /etc/xinetd.d/swat File

The stunnel daemon actually intercepts port 901 traffic on behalf of swat-stunnel. You'll need to disable SWAT to prevent a conflict.

Edit The /etc/services file To create a Secure SWAT entry

The xinetd daemon searches /etc/services file for ports and services that match those listed in each configuration file in the /etc/xinetd.d directory. If the daemon doesn't find a match it ignores the configuration file.
We now have to edit /etc/services to include our new swat-stunnel file like this.
swat-stunnel    902/tcp     # Samba Web Administration Tool (Stunnel)

Activate swat-stunnel

You can then start the new swat-stunnel application with the chkconfig command. You'll also need to shutdown regular swat beforehand.
[root@bigboy xinetd.d]# chkconfig swat off
[root@bigboy xinetd.d]# chkconfig swat-stunnel on

Start stunnel

Now start stunnel for the encryption to take place.
[root@bigboy xinetd.d]# stunnel
Note: In Fedora Core 2 you may get a cryptonet error when starting stunnel as in:
Unable to open "/dev/cryptonet"

This is caused by an incompatibility with the hwcrypto RPM used for hardware-, not software-based encryption. You need to uninstall hwcrypto to get stunnel to work correctly.
[root@bigboy xinetd.d]# rpm -e hwcrypto

You will then have to stop stunnel, restart xinetd and start stunnel again. After this, stunnel should begin to function correctly. Unfortunately stunnel doesn't have a startup script in the /etc/init.d directory and needs to be terminated manually using the pkill command.
[root@bigboy xinetd.d]# pkill stunnel
[root@bigboy xinetd.d]# stunnel

Making stunnel Start at Boot Time

As stunnel doesn't have a startup script, you'll need to add a reference to the stunnel program in your /etc/rc.local file for encrypted SWAT to work on your system. The easiest way to do this is using the which command and appending its output to the /etc/rc.local file.
[root@bigboy tmp]# which stunnel >> /etc/rc.local
Verify the contents of the /etc/rc.local file by using the cat command. The entry for stunnel should be at the very bottom.
[root@bigboy tmp]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/usr/sbin/stunnel
[root@bigboy tmp]#

Test Secure SWAT

Your Samba server should now be listening on both port 901 and 902 as shown by the netstat -an command that follows. The server will accept remote connections on port 901 only.
[root@bigboy xinetd.d]# netstat -an
...
...
tcp        0      0 0.0.0.0:901      0.0.0.0:*        LISTEN
tcp        0      0 127.0.0.:902     0.0.0.0:*        LISTEN
...
...
[root@bigboy xinetd.d]#

Test The Secure SWAT Login

Point your browser to the Samba server to make an HTTPS connection on port 901.
https://server-ip-address:901/
You will be prompted for the Linux root user username and password. There will be a delay of about 60 to 75 seconds with each login.

Troubleshooting Secure SWAT

Sometimes you'll make mistakes in the stunnel.conf file but changes to this file take effect only after stunnel has been restarted. Unfortunately, there is no stunnel script in the /etc/init.d directory to easily stop and restart it. You have to use the pkill command to stop it and the stunnel command to start it again:
[root@bigboy tmp]# pkill stunnel ; stunnel
Make sure the file permissions and ownership on the stunnel.pem file are correct and that SWAT is always permanently off, but swat-stunnel is permanently on.
You can also refer to, "Simple Network Troubleshooting", to isolate connectivity issues between the SWAT client and Samba server on TCP port 901 amongst other things.

Saturday, December 3, 2011

How SWAT Makes Samba Simpler - PART3


SWAT, Samba's web based configuration tool enables you configure your smb.conf file without you needing to remember all the formatting. Each SWAT screen is actually a form that covers a separate section of the smb.conf file into which you fill in the desired parameters. For ease of use, each parameter box has its own online help. Figure 10-1 shows the main SWAT login screen.

Figure 10-1 Samba SWAT Main Menu

Swat-main.gif

Basic SWAT Setup

You must always remember that SWAT edits the smb.conf file but also strips out any comments you may have manually entered into it beforehand. The original Samba smb.conf file has many worthwhile comments in it, you should save a copy as a reference before proceeding with SWAT. For example, you could save the original file with the name /etc/samba/smb.conf.original as in:
[root@bigboy tmp]# cp /etc/samba/smb.conf /etc/samba/smb.conf.original
As you can see, using SWAT requires some understanding of the smb.conf file parameters because it eliminates these comments. Become familiar with the most important options in this file before proceeding with SWAT.
SWAT doesn't encrypt your login password. Because this could be a security concern in a corporate environment you might want to create a Samba administrator user that has no root privileges or only enable SWAT access from the GUI console or localhost.
The enabling and disabling, starting and stopping of SWAT is controlled by xinetd, which is covered in Chapter 16, "Telnet, TFTP, and xinetd", via a configuration file named /etc/xinetd.d/swat. Here is a sample:
service swat
{

   port            = 901
   socket_type     = stream
   protocol        = tcp
   wait            = no
   user            = root
   server          = /usr/sbin/swat
   log_on_failure  += USERID
   disable         = no
   only_from       = localhost

}
The file's formatting is fairly easy to understand, especially as there are only two entries of interest.
  • The disable parameter must be set to no to accept connections. This can automatically be switched between yes and no as we will see later.
  • The default configuration only allows SWAT web access from the VGA console only as user root on port 901 with the Linux root password. This means you'll have to enter "http://127.0.0.1:901" in your browser to get the login screen.
You can make SWAT accessible from other servers by adding IP address entries to the only_from parameter of the SWAT configuration file. Here's an example of an entry to allow connections only from 192.168.1.3 and localhost. Notice that there are no commas between the entries.
only_from = localhost 192.168.1.3
Therefore in this case you can also configure Samba on your Linux server bigboy IP with address 192.168.1.100 from PC 192.168.1.3 using the URL http://192.168.1.100:901.
Remember that most firewalls don't allow TCP port 901 through their filters. You may have to adjust your rules for this traffic to pass.

Controlling SWAT

As with all xinetd-controlled applications, the chkconfig command automatically modifies the disable field accordingly in the configuration file and activates the change.
Before SWAT can be used, the xinetd program which controls it must be activated in advance. You can start/stop/restart xinetd after boot time using the xinetd initialization script as in the examples below:
[root@bigboy tmp]# service xinetd start
[root@bigboy tmp]# service xinetd stop
[root@bigboy tmp]# service xinetd restart
Just like most Linux systems applications, you can configure xinetd to start at boot time using the chkconfig command:
[root@bigboy tmp]# chkconfig xinetd on
To activate SWAT use:
[root@bigboy tmp] chkconfig swat on
To deactivate SWAT use:
[root@bigboy tmp] chkconfig swat off