Ubuntu Server Guide: Part 3
You can use the CVSROOT environment variable to store the CVS root directory. Once you export the CVSROOT environment variable, you can avoid using -d option to above cvs command.
The string new_project is a vendor tag, and start is a release tag. They serve no purpose in this context, but since CVS requires them, they must be present.
When you add a new project, the CVS user you use must have write access to the CVS repository (/var/lib/cvs). By default, the src group has write access to the CVS repository. So, you can add the user to this group, and he can then add and manage projects in the CVS repository.
References
Subversion Home Page [http://subversion.tigris.org/]
Subversion Book [http://svnbook.red-bean.com/]
CVS Manual [http://ximbiot.com/cvs/manual/cvs-1.11.21/cvs_toc.html]
13. Databases
Ubuntu provides two Database servers. They are:
• MySQL™
• PostgreSQL
They are available in the main repository. This section explains how to install and
configure these database servers.
13.1. MySQL
MySQL is a fast, multi-threaded, multi-user, and robust SQL database server. It is
intended for mission-critical, heavy-load production systems as well as for embedding into
mass-deployed software.
13.1.1. Installation
To install MySQL, run the following command from a terminal prompt:
sudo apt-get install mysql-server mysql-client
Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:
sudo netstat -tap | grep mysql
When you run this command, you should see the following line or something similar:
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
If the server is not running correctly, you can type the following command to start it:
sudo /etc/init.d/mysql restart
13.1.2. Configuration
By default, the administrator password is not set. Once you install MySQL, the first
thing you must do is to configure the MySQL administrator password. To do this, run the following commands:
sudo mysqladmin -u root password newrootsqlpassword
sudo mysqladmin -u root -h localhost password newrootsqlpassword
You can edit the /etc/mysql/my.cnf file to configure the basic settings -- log file, port number, etc. Refer to /etc/mysql/my.cnf file for more details.
13.2. PostgreSQL
PostgreSQL is an object-relational database system that has the features of traditional commercial database systems with enhancements to be found in next-generation DBMS systems.
13.2.1. Installation
To install PostgreSQL, run the following command in the command prompt:
sudo apt-get install postgresql
Once the installation is complete, you should configure the PostgreSQL server based on your needs, although the default configuration is viable.
13.2.2. Configuration
By default, connection via TCP/IP is disabled. PostgreSQL supports multiple client authentication methods. By default, IDENT authentication method is used. Please refer the PostgreSQL Administrator's Guide [http://www.postgresql.org/docs/8.1/static/admin.html].
The following discussion assumes that you wish to enable TCP/IP connections and use the MD5 method for client authentication. PostgreSQL configuration files are stored in the /etc/postgresql//main directory. For example, if you install PostgreSQL 7.4, the configuration files are stored in the /etc/postgresql/7.4/main directory.
To configure ident authentication, add entries to the /etc/postgresql/7.4/main/pg_ident.conf file.
To enable TCP/IP connections, edit the file /etc/postgresql/7.4/main/postgresql.conf
Locate the line #tcpip_socket = false and change it to tcpip_socket = true. You may also edit all other parameters, if you know what you are doing! For details, refer to the configuration file or to the PostgreSQL documentation.
By default, the user credentials are not set for MD5 client authentication. So, first it is necessary to configure the PostgreSQL server to use trust client authentication, connect to the database, configure the password, and revert the configuration back to use MD5 client authentication. To enable trust client authentication, edit the file /etc/postgresql/7.4/main/pg_hba.conf
Comment out all the existing lines which use ident and MD5 client authentication and add
the following line:
local all postgres trust sameuser
Then, run the following command to start the PostgreSQL server:
sudo /etc/init.d/postgresql start
Once the PostgreSQL server is successfully started, run the following command at a
terminal prompt to connect to the default PostgreSQL template database
psql -U postgres -d template1
The above command connects to PostgreSQL database template1 as user postgres.
Once you connect to the PostgreSQL server, you will be at a SQL prompt. You can run
the following SQL command at the psql prompt to configure the password for the user
postgres.
template1=# ALTER USER postgres with encrypted password 'your_password';
After configuring the password, edit the file /etc/postgresql/7.4/main/pg_hba.conf to
use MD5 authentication:
Comment the recently added trust line and add the following line:
local all postgres md5 sameuser
The above configuration is not complete by any means.
Please refer the PostgreSQL Administrator's Guide
[http://www.postgresql.org/docs/8.1/static/admin.html] to configure more
parameters.
14. Email Services
The process of getting an email from one person to another over a network or the Internet involves many systems working together. Each of these systems must be correctly configured for the process to work. The sender uses a Mail User Agent (MUA), or email client, to send the message through one or more Mail transfer Agents (MTA), the last of which will hand it off to a Mail Delivery Agent (MDA) for delivery to the recipient's mailbox, from which it will be retrieved by the recipient's email client, usually via a POP3 or IMAP server.
14.1. Postfix
Postfix is the default Mail Transfer Agent (MTA) in Ubuntu. It attempts to be fast and easy to administer and secure. It is compatible with the MTA sendmail. This section explains how to install and configure postfix. It also explains how to set it up as an SMTP server using a secure connection (for sending emails securely).
14.1.1. Installation
To install postfix with SMTP-AUTH and Transport Layer Security (TLS), run the following command:
sudo apt-get install postfix
Simply press return when the installation process asks questions, the configuration will be done in greater detail in the next stage.
14.1.2. Basic Configuration
To configure postfix, run the following command:
sudo dpkg-reconfigure postfix
The user interface will be displayed. On each screen, select the following values:
• Ok
• Internet Site
• NONE
• mail.example.com
• mail.example.com, localhost.localdomain, localhost
• No
• 127.0.0.0/8
• Yes
• 0
• +
• all
Replace mail.example.com with your mail server hostname.
14.1.3. SMTP Authentication
The next steps are to configure postfix to use SASL for SMTP AUTH. Rather than editing the configuration file directly, you can use the postconf command to configure all postfix parameters. The configuration parameters will be stored in /etc/postfix/main.cf file.
Later if you wish to re-configure a particular parameter, you can either run the command or change it manually in the file.
1. Configure Postfix to do SMTP AUTH using SASL (saslauthd):
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf
2. Next, configure the digital certificate for TLS. When asked questions, follow the
instructions and answer appropriately.
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
mv smtpd.key /etc/ssl/private/
mv smtpd.crt /etc/ssl/certs/
mv cakey.pem /etc/ssl/private/
mv cacert.pem /etc/ssl/certs/
You can get the digital certificate from a certificate authority. Alternatively,
you can create the certificate yourself. Refer to Section 10.3.4, “Creating a
Self-Signed Certificate” [p. 53] for more details.
3. Configure Postfix to do TLS encryption for both incoming and outgoing mail:
postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/ssl/private/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'
postconf -e 'myhostname = mail.example.com'
After you run all the commands, the SMTP AUTH is configured with postfix.
The self-signed cerficiate is created for TLS and it is configured with postfix.
Now, the file /etc/postfix/main.cf should look like this
[../sample/postfix_configuration].
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
The postfix initial configuration is complete. Run the following command to start postfix daemon:
sudo /etc/init.d/postfix start
Now the postfix daemon is installed, configured and run successfully. Postfix supports SMTP AUTH as defined in RFC2554 [ftp://ftp.isi.edu/in-notes/rfc2554.txt]. It is based on SASL [ftp://ftp.isi.edu/in-notes/rfc2222.txt]. However it is still necessary to set up SASL authentication before you can use SMTP.
14.1.4. Configuring SASL
The libsasl2, sasl2-bin and libsasl2-modules are necessary to enable SMTP AUTH using SASL. You can install these applications if you have not installed them already.
apt-get install libsasl2 sasl2-bin
A few changes are necessary to make it work properly. Because Postfix runs chrooted in /var/spool/postfix, SASL needs to be configured to run in the false root (/var/run/saslauthd becomes /var/spool/postfix/var/run/saslauthd):
mkdir -p /var/spool/postfix/var/run/saslauthd
rm -rf /var/run/saslauthd
To activate saslauthd, edit the file /etc/default/saslauthd, and change or add the START variable. In order to configure saslauthd to run in the false root, add the PWDIR, PIDFILE and PARAMS variables. Finally, configure the MECHANISMS variable to your liking. The file should look like this:
# This needs to be uncommented before saslauthd will be run
# automatically
START=yes
PWDIR="/var/spool/postfix/var/run/saslauthd"
PARAMS="-m ${PWDIR}"
PIDFILE="${PWDIR}/saslauthd.pid"
# You must specify the authentication mechanisms you wish to use.
# This defaults to "pam" for PAM support, but may also include
# "shadow" or "sasldb", like this:
# MECHANISMS="pam shadow"
MECHANISMS="pam"
If you prefer, you can use shadow instead of pam. This will use MD5 hashed password transfer and is perfectly secure. The username and password needed to authenticate will be those of the users on the system you are using on the server.
Next, update the dpkg "state" of /var/spool/portfix/var/run/saslauthd. The saslauthd init script uses this setting to create the missing directory with the appropriate permissions and ownership:
dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/saslauthd
14.1.5. Testing
SMTP AUTH configuration is complete. Now it is time to start and test the setup. You can run the following command to start the SASL daemon:
sudo /etc/init.d/saslauthd start
To see if SMTP-AUTH and TLS work properly, run the following command:
telnet mail.example.com 25
After you have established the connection to the postfix mail server, type:
ehlo mail.example.com
If you see the following lines among others, then everything is working perfectly. Type
quit to exit.
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
14.2. Exim4
Exim4 is is another Message Transfer Agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the internet. Exim can be installed in place of sendmail, although the configuration of exim is quite different to that of sendmail.
14.2.1. Installation
To install exim4, run the following command:
sudo apt-get install exim4 exim4-base exim4-config
14.2.2. Configuration
To configure exim4, run the following command:
sudo dpkg-reconfigure exim4-config
The user interface will be displayed. The user interface lets you configure many parameters. For example, In exim4 the configuration files are split among multiple files. If you wish to have them in one file you can configure accordingly in this user interface.
All the parameters you configure in the user interface are stored in /etc/exim4/update-exim4.conf.conf file. If you wish to re-configure, either you re-run the configuration wizard or manually edit this file using your favourite editor. Once you configure, you can run the following command to generate the master configuration file:
sudo update-exim4.conf
The master configuration file, is generated and it is stored in /var/lib/exim4/config.autogenerated.
At any time, you should not edit the master configuration file, /var/lib/exim4/config.autogenerated manually. It is updated automatically every time you run update-exim4.conf
You can run the following command to start exim4 daemon.
sudo /etc/init.d/exim4 start
TODO: This section should cover configuring SMTP AUTH with exim4.
14.3. Dovecot Server
Dovecot is a Mail Delivery Agent, written with security primarily in mind. It supports the major mailbox formats: mbox or Maildir. This section explain how to set it up as an imap or pop3 server.
14.3.1. Installation
To install dovecot, run the following command in the command prompt:
sudo apt-get install dovecot-common dovecot-imapd dovecot-pop3d
14.3.2. Configuration
To configure dovecot, you can edit the file /etc/dovecot/dovecot.conf. You can choose the protocol you use. It could be pop3, pop3s (pop3 secure), imap and imaps (imap secure).
A description of these protocols is beyond the scope of this guide. For further information, refer to the wikipedia articles on POP3 [http://en.wikipedia.org/wiki/POP3] and IMAP http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol].
IMAPS and POP3S are more secure that the simple IMAP and POP3 because they use SSL encryption to connect. Once you have chosen the protocol, amend the following line in the file /etc/dovecot/dovecot.conf:
protocols = pop3 pop3s imap imaps
It enables the protocols when dovecot is started. Next, add the following line in pop3 section in the file /etc/dovecot/dovecot.conf:
pop3_uidl_format = %08Xu%08Xv
Next, choose the mailbox you use. Dovecot supports maildir and mbox formats. These are the most commonly used mailbox formats. They both have their own benefits and they are discussed on the dovecot website [http://dovecot.org/doc/configuration.txt].
Once you have chosen your mailbox type, edit the file /etc/dovecot/dovecot.conf and
change the following line:
default_mail_env = maildir:~/Maildir # (for maildir)
or
default_mail_env = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox)
You should configure your Mail Trasport Agent (MTA) to transfer the incoming mail to this type of mailbox if it is different from the one you have configured.
Once you have configured dovecot, start the dovecot daemon in order to test your setup:
sudo /etc/init.d/dovecot start
If you have enabled imap, or pop3, you can also try to log in with the commands telnet localhost pop3 or telnet localhost imap2. If you see something like the following, the installation has been successful:
bhuvan@rainbow:~$ telnet localhost pop3
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
+OK Dovecot ready.
14.3.3. Dovecot SSL Configuration
To configure dovecot to use SSL, you can edit the file /etc/dovecot/dovecot.conf and
amend following lines:
ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem
ssl_disable = no
disable_plaintext_auth = no
The cert and key files are created automatically by dovecot when you install it. Please note that these keys are not signed and will give "bad signature" errors when connecting from a client. To avoid this, you can use commercial certificates, or even better, you can use your own SSL certificates.
14.3.4. Firewall Configuration for an Email Server
To access your mail server from another computer, you must configure your firewall to allow connections to the server on the necessary ports.
• IMAP - 143
• IMAPS - 993
• POP3 - 110
• POP3S - 995
14.4. Mailman
Mailman is an open source program for managing electronic mail discussions and e-newsletter lists. Many open source mailing lists (including all the Ubuntu mailing lists [http://lists.ubuntu.com]) use Mailman as their mailing list software. It is powerful and easy to install and maintain.
14.4.1. Installation
Mailman provides a web interface for the administrators and users. So, it requires apache with mod_perl support. Mailman uses an external mail server to send and receive emails. It works perfectly with the following mail servers:
• Postfix
• Exim
• Sendmail
• Qmail
We will see how to install mailman, the apache web server and the Exim mail server. If you wish to install mailman with a different mail server, please refer to the references section.
14.4.1.1. Apache2
To install apache2 you refer to Section 10.1, “Installation” [p. 46].
14.4.1.2. Exim4
To install Exim4 you run the following commands at a terminal prompt:
sudo apt-get install exim4
sudo apt-get install exim4-base
sudo apt-get install exim4-config
Once exim4 is installed, the configuration files are stored in the /etc/exim4 directory. In ubuntu, by default, the exim4 configuration files are split across different files. You can change this behavior by changing the following variable in the /etc/exim4/update-exim4.conf file:
• dc_use_split_config='true'
14.4.1.3. Mailman
To install Mailman, run following command at a terminal prompt:
sudo apt-get install mailman
It copies the installation files in /var/lib/mailman directory. It installs the CGI scripts in /usr/lib/cgi-bin/mailman directory. It creates list linux user. It creates the list linux group.
The mailman process will be owned by this user.
14.4.2. Configuration
This section assumes you have successfully installed mailman, apache2, and exim4. Now you just need to configure them.
14.4.2.1. Apache2
Once apache2 is installed, you can add the following lines in the
/etc/apache2/apache2.conf file:
Alias /images/mailman/ "/usr/share/images/mailman/"
Alias /pipermail/ "/var/lib/mailman/archives/public/"
Mailman uses apache2 to render its CGI scripts. The mailman CGI scripts are installed in the /usr/lib/cgi-bin/mailman directory. So, the mailman url will be http://hostname/cgi-bin/mailman/. You can make changes to the /etc/apache2/apache2.conf file if you wish to change this behavior.
14.4.2.2. Exim4
Once Exim4 is installed, you can start the Exim server using the following command from
a terminal prompt:
sudo apt-get /etc/init.d/exim4 start
In order to make mailman work with exim4, you need to configure exim4. As mentioned earlier, by default, exim4 uses multiple configuration files of different types. For details, please refer to the Exim [http://www.exim.org] website. To run mailman, we should add new a configuration file to the following configuration types:
• Main
• Transport
• Router
Exim creates a master configuration file by sorting all these mini configuration files. So, the order of these configuration files is very important.
14.4.2.3. Main
All the configuration files belonging to the main type are stored in the /etc/exim4/conf.d/main/ directory. You can add the following content to a new file, named 04_exim4-config_mailman:
# start
# Home dir for your Mailman installation -- aka Mailman's prefix
# directory.
# On Ubuntu this should be "/var/lib/mailman"
# This is normally the same as ~mailman
MM_HOME=/var/lib/mailman
#
# User and group for Mailman, should match your --with-mail-gid
# switch to Mailman's configure script. Value is normally "mailman"
MM_UID=list
MM_GID=list
#
# Domains that your lists are in - colon separated list
# you may wish to add these into local_domains as well
domainlist mm_domains=hostname.com
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# These values are derived from the ones above and should not need # editing unless you have munged your mailman installation
#
# The path of the Mailman mail wrapper script
MM_WRAP=MM_HOME/mail/mailman
#
# The path of the list config file (used as a required file when
# verifying list addresses)
MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck
# end
14.4.2.4. Transport
All the configuration files belonging to transport type are stored in the /etc/exim4/conf.d/transport/ directory. You can add the following content to a new file named 40_exim4-config_mailman:
mailman_transport:
driver = pipe
command = MM_WRAP \
'${if def:local_part_suffix \
{${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
{post}}' \
$local_part
current_directory = MM_HOME
home_directory = MM_HOME
user = MM_UID
group = MM_GID
14.4.2.5. Router
All the configuration files belonging to router type are stored in the /etc/exim4/conf.d/router/ directory. You can add the following content in to a new file named 101_exim4-config_mailman:
mailman_router:
driver = accept
require_files = MM_HOME/lists/$local_part/config.pck
local_part_suffix_optional
local_part_suffix = -bounces : -bounces+* : \
-confirm+* : -join : -leave : \
-owner : -request : -admin
transport = mailman_transport
The order of main and transport configuration files can be in any order. But, the order of router configuration files must be the same. This particular file must appear before the 200_exim4-config_primary file. These two configuration files contain same type of information. The first file takes the precedence. For more details, please refer to the references section.
14.4.2.6. Mailman
Once mailman is installed, you can run it using the following command:
sudo /etc/init.d/mailman start
Once mailman is installed, you should create the default mailing list. Run the following
command to create the mailing list:
sudo /usr/sbin/newlist mailman
Enter the email address of the person running the list: bhuvan at ubuntu.com
Initial mailman password:
To finish creating your mailing list, you must edit your /etc/aliases (or equivalent) file by adding the following lines, and possibly running the `newaliases' program:
## mailman mailing list
mailman: "|/var/lib/mailman/mail/mailman post mailman"
mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman"
mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman"
mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman"
mailman-join: "|/var/lib/mailman/mail/mailman join mailman"
mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman"
mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman"
mailman-request: "|/var/lib/mailman/mail/mailman request mailman"
mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"
Hit enter to notify mailman owner...
#
We have configured exim to recognize all emails from mailman. So, it is not mandatory to make any new entries in /etc/aliases. If you have made any changes to the configuration files, please ensure that you restart those services before continuing to next section.
14.4.3. Administration
We assume you have a default installation. The mailman cgi scripts are still in /usr/lib/cgi-bin/mailman/ directory. Mailman provides a web based administration facility.
To access this page, point your browser to the following url:
http://hostname/cgi-bin/mailman/admin
The default mailing list, mailman, will appear in this screen. If you click the mailing list name, it will ask for your authentication password. If you enter the correct password, you will be able to change administrative settings of this mailing list. You can create a new mailing list using command line utility (/usr/sbin/newlist). Alternatively, you can create a new mailing list using web interface.
14.4.4. Users
Mailman provides a web based interface for users. To access this page, point your browser to the following url:
http://hostname/cgi-bin/mailman/listinfo
The default mailing list, mailman, will appear in this screen. If you click the mailing list name, it will display the subscription form. You can enter your email address, name (optional), and password to subscribe. An email invitation will be sent to you. You can follow the instructions in the email to subscribe.
14.4.5. References
GNU Mailman - Installation Manual [http://www.list.org/mailman-install/index.html]
HOWTO - Using Exim 4 and Mailman 2.1 together
[http://www.exim.org/howto/mailman21.html]
Chapter 5. Windows Networking
Computer networks are often comprised of diverse systems, and while operating a network made up entirely of Ubuntu desktop and server computers would certainly be fun, some network environments must consist of both Ubuntu and Microsoft® Windows® systems working together in harmony. This section of the Ubuntu Server Guide introduces principles and tools used in configuring your Ubuntu Server for sharing network resources with Windows computers.
Windows Networking
1. Introduction
Successfully networking your Ubuntu system with Windows clients involves providing and integrating with services common to Windows environments. Such services assist the sharing of data and information about the computers and users involved in the network, and may be classified under three major categories of functionality:
• File and Printer Sharing Services. Using the Server Message Block (SMB) protocol to facilitate the sharing of files, folders, volumes, and the sharing of printers throughout the network.
• Directory Services. Sharing vital information about the computers and users of the network with such technologies as the Lightweight Directory Access Protocol (LDAP) and Microsoft Active Directory®.
• Authentication and Access. Establishing the identity of a computer or user of the network and determining the information the computer or user is authorized to access using such principles and technologies as file permissions, group policies, and the Kerberos authentication service.
Fortunately, your Ubuntu system may provide all such facilities to Windows clients and share network resources among them. One of the principle pieces of software your Ubuntu system includes for Windows networking is the SAMBA suite of SMB server applications and tools. This section of the Ubuntu Server Guide will briefly introduce the installation and limited configuration of the SAMBA suite of server applications and
utilities. Additional, detailed documentation and information on SAMBA is beyond the scope of this documentation, but exists on the SAMBA website [http://www.samba.org].
2. Installing SAMBA
At the prompt enter the following command to install the SAMBA server applications:
sudo apt-get install samba
3. Configuring SAMBA
You may configure the SAMBA server by editing the /etc/samba/smb.conf file to change the default settings or add new settings. More information about each setting is available in the comments of the /etc/samba/smb.conf file or by viewing the /etc/samba/smb.conf manual page from the prompt with the following command typed at a terminal prompt:
man smb.conf
Prior to editing the configuration file, you should make a copy of the original file and protect it from writing so you will have the original settings as a reference and to re-use as necessary.
Backup the /etc/samba/smb.conf file:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.original
Now, edit the /etc/samba/smb.conf file and make your changes.
3.1. Server
In addition to the SAMBA suite of file and printer sharing server applications, Ubuntu also includes other powerful server applications designed to provide additional network serverfunctionality to Windows clients similar to the functionality provided by actual Windows servers. For example, Ubuntu offers centralized management of network resources such as computers and users via Directory Services, and facilitates the identification, and authorization of computers and users via Authentication Services.
The following sections will discuss SAMBA and the supporting technologies, such as Lightweight Directory Access Protocol (LDAP) server, and Kerberos authentication server in more detail. You will also learn about some of the available configuration directives available the SAMBA configuration file which facilitate network integration with Windows clients and servers.
3.1.1. Active Directory
Active Directory is a proprietary implementation of Directory Services by Microsoft, and is used to provide a means to share information about network resources and users.
In addition to providing a centralized source of such information, Active Directory also acts as a centralized authentication security authority for the network. Active directory combines capabilities traditionally found in separate, specialized directory systems to simplify integration, management, and security of network resources. The SAMBA package may be configured to use Active Directory services from a Windows Domain
Controller.
3.1.1.1. LDAP
The LDAP server application provides Directory Services functionality to Windows
computers in a manner very similar to Microsoft Active Directory services. Such services
include managing the identities and relationships of computers, users, and groups of
computers or users that participate in the network, and providing a consistent means
to describe, locate, and manage these resources. The freely available implementation
of LDAP available for your Ubuntu system is called OpenLDAP. The server daemons
responsible for handling OpenLDAP directory requests and the propagation of directory
data from one LDAP server to another on Ubuntu, are slapd and slurpd. OpenLDAP may
be used in conjunction with SAMBA to provide File, Print, and Directory services in much
the same way a Windows Domain Controller does so long as SAMBA is compiled with
LDAP support.
3.1.1.2. Kerberos
The Kerberos authentication security system is a standardized service for providing
authentication to computers and users by means of a centralized server which grants
encrypted authorization tickets accepted for authorization by any other computer using
Kerberos. Benefits of Kerberos authentication include mutual authentication, delegated
authentication, interoperability, and simplified trust management. The primary server
daemons for handling the Kerberos authentication and Kerberos database administration
on Ubuntu are krb5kdc and kadmin. SAMBA may use Kerberos as a mechanism for
authenticating computers and users against a Windows Domain Controller. To do so,
the Ubuntu system must have Kerberos installed, and the /etc/samba/smb.conf must
be modified to select the the proper realm and security mode. For example, edit the
/etc/samba/smb.conf file and add the values:
realm = DOMAIN_NAME
security = ADS
to the file, and save the file.
Be sure to replace the token DOMAIN_NAME in the example above with the
actual name of your specific Windows Domain.
You will need to restart the SAMBA daemons to effect these changes. Restart the SAMBA
daemons with the following command entered at a terminal prompt:
sudo /etc/init.d/samba restart
3.1.2. Computer Accounts
Computer Accounts are used in Directory Services to uniquely identify computer systems
participating in a network, and are even treated in the same manner as users in terms of
security. Computer accounts may have passwords just as user accounts do, and are subject
to authorization to network resources in the same manner as user accounts. For example,
if a network user, with a valid account for a particular network attempts to authenticate
with a network resource from a computer which does not have a valid computer account,
depending upon policies enforced on the network, the user may be denied access to the
resource if the computer the user is attempting authentication from is considered to be an
unauthorized computer.
A computer account may be added to the SAMBA password file, provided the name of the
computer being added exists as a valid user account in the local password database first.
The syntax for adding a computer or machine account to the SAMBA password file is to
use the smbpasswd command from a terminal prompt as follows:
sudo smbpasswd -a -m COMPUTER_NAME
Be sure to replace the token COMPUTER_NAME in the example above with the
actual name of the specific computer you wish to add a machine account for.
3.1.3. File Permissions
File Permissions define the explicit rights a computer or user has to a particular directory,
file, or set of files. Such permissions may be defined by editing the /etc/samba/smb.conf
file and specifying the explicit permissions of a defined file share. For example, if
you have defined a SAMBA share called sourcedocs and wish to give read-only
permissions to the group of users known as planning, but wanted to allow writing to the
share by the group called authors and the user named richard, then you could edit the
/etc/samba/smb.conf file, and add the following entries under the [sourcedocs] entry:
read list = @planning
write list = @authors, richard
Save the /etc/samba/smb.conf for the changes to take effect.
Another possible permission is to declare administrative permissions to a particular
shared resource. Users having administrative permissions may read, write, or modify
any information contained in the resource the user has been given explicit administrative
permissions to. For example, if you wanted to give the user melissa administrative
permissions to the example sourcedocs share, you would edit the /etc/samba/smb.conf
file, and add the following line under the [sourcedocs] entry:
admin users = melissa
Save the /etc/samba/smb.conf for the changes to take effect.
3.2. Clients
Ubuntu includes client applications and capabilities for accessing network resources
shared with the SMB protocol. For example, a utility called smbclient allows for accessing
remote shared file-systems, in a manner similar to a File Transfer Protocol (FTP) client.
To access a shared folder resource known as documents offered by a remote Windows
computer named bill using smbclient for example, one would enter a command similar to
the following at the prompt:
smbclient //bill/documents -U
You will then be prompted for the password for the user name specified after the -U
switch, and upon successful authentication, will be presented with a prompt where
commands may be entered for manipulating and transferring files in a syntax similar to that
used by non-graphical FTP clients. For more information on the smbclient utility, read the
utility's manual page with the command:
man smbclient
Local mounting of remote network resources using the SMB protocol is also possible
using the mount command. For example, to mount a shared folder named project-code
on a Windows server named development as the user dlightman to your Ubuntu system's
/mnt/pcode mount-point, you would issue this command at the prompt:
mount -t smbfs -o username=dlightman //development/project-code /mnt/pcode
You will then be prompted for the user password, and after successfully authenticating, the
contents of the shared resource will be available locally via the mount-point specified as
the last argument to the mount command. To disconnect the shared resource, simply use
the umount command as you would with any other mounted file system. For example:
umount /mnt/pcode
3.2.1. User Accounts
User Accounts define persons with some level of authorization to use certain computer
and network resources. Typically, in a network environment, a user account is provided
to each person allowed to access a computer or network, where policies and permissions
then define what explicit rights that user account has access to. To define SAMBA network
users for your Ubuntu system, you may use the smbpasswd command. For example to add
a SAMBA user to your Ubuntu system with the user name jseinfeld, you would enter this
command at the prompt:
smbpasswd -a jseinfeld
The smbpasswd application will then prompt you to enter a password for the user:
New SMB password:
Enter the password you wish to set for the user, and the smbpasswd application will ask
you to confirm the password:
Retype new SMB password:
Confirm the password, and smbpasswd will add the entry for the user to the SAMBA
password file.
3.2.2. Groups
Groups define a collection of computers or users which have a common level of access
to particular network resources and offer a level of granularity in controlling access to
such resources. For example, if a group qa is defined and contains the users freda, danika,
and rob and a second group support is defined and consists of users danika, jeremy, and
vincent then certain network resources configured to allow access by the qa group will
subsequently enable access by freda, danika, and rob, but not jeremy or vincent. Since the
user danika belongs to both the qa and support groups, she will be able to access resources
configured for access by both groups, whereas all other users will have only access to
resources explicitly allowing the group they are part of.
When defining groups in the SAMBA configuration file, /etc/samba/smb.conf
the recognized syntax is to preface the group name with an "@" symbol. For
example, if you wished to define a group named sysadmin in a certain section of the
/etc/samba/smb.conf, you would do so by entering the group name as @sysadmin.
3.2.3. Group Policy
Group Policy defines certain SAMBA configuration settings pertaining to the Domain or
Workgroup computer accounts belong to, and other global settings for the SAMBA server.
For example, if the SAMBA server belongs to a Workgroup of Windows computers called
LEVELONE, then the /etc/samba/smb.conf could be edited, and the following value
changed accordingly:
workgroup = LEVELONE
Save the file and restart the SAMBA daemons to affect the change.
Other important global policy settings include the server string which defines the
NETBIOS server name reported by your Ubuntu system to other machines on the
Windows-based network. This is the name your Ubuntu system will be recognized as by
Windows clients and other computers capable of browsing the network with the SMB
protocol. Additionally, you may specify the name and location of the SAMBA server's log
file by using the log file directive in the /etc/samba/smb.conf file.
Some of the additional directives governing global group policy include specification of
the global nature of all shared resources. For example, placing certain directives under the
[global] heading of the /etc/samba/smb.conf file will affect all shared resources unless
an overriding directive is placed under a particular shared resource heading. You specify
all shares are browseable by all clients on the network by placing a browseable directive,
which takes a Boolean argument, under the [global] heading in the /etc/samba/smb.conf.
That is, if you edit the file and add the line:
browseable = true
under the [global] section of /etc/samba/smb.conf, then all shares provided by your
Ubuntu system via SAMBA will be browseable by all authorized clients, unless a specific
share contains a browseable = false directive, which will override the global directive.
Other examples which work in a similar manner, are the public and writeable directives.
The public directive accepts a Boolean value and decides whether a particular shared
resource is visible by all clients, authorized or not. The writeable directive also takes a Boolean value and defines whether a particular shared resource is writable by any and all
network clients.






digg it
del.icio.us

