Archive

Archive for the ‘Linux Commands’ Category

Installing a RAID on “hardware” with fakeraid and Ubuntu

October 10th, 2011 No comments

If you have motherboards with raid directly on the plate and want to install Linux, you probably need to fall back on software RAID … unless your controller is supported by the project fakeraid. This is not ‘a guide to replace the complete how-to but rather a reminder of the past 2 days to install one server supermicro raid with the “hardware” …

Therefore, our configuration was quite simple: 3 Disc 2 in raid 1 and a separate back up the historical data with our automatic script. we created a RAID from the bios screen text by choosing the first two records and making the raid sync (which took about one hour or so).

In these cases the problem stems from the fact that the installer of the distribution have to be aware of how to manage the controller to be able to install the operating system. Also, if in init RAM disk that is made from grub dmraid is not added to the module, the system, although installed will not start on the next reboot.

The distribution and ‘fell on a ubuntu server how to fakeraid of the page we read that the 8.10 alternate or server is already’ in the process of recognition of fake raid setup then, although support for hardy is 5 years instead of the ‘ dell’ intrepid year and a half, for convenience we have installed it. In fact everything at startup ‘and the system went smoothly, and’ installed without any major problems … The kernel has recognized the device as /dev/mapper/ddf1_root and the two partitions /dev/mapper/ddf1_root1 and /dev/mapper/ddf1_root2

I’ll Tell you to avoid wasting your time precious: Currently, the kernel that comes with Intrepid has a problem of restarting the operating system from the first reboot after installation: Although the form was present in the initrd and despite dmraid with grub and one thousand depopulation that with udev to force the dmraid we could not restart automatically to the operating system: every time we jumped in the busybox shell temporarily as photography [PHOTOS]. The strange thing is that if by hand, activating the raid with dmraid-ay command and then pressing Ctrl + D, voila here is share our ubuntu …

So how to solve? simply install the kernel 2.6.24-23-server hardy! no problem with the boot. So if you want a server a bit more ‘secure, with support for 5 years, I recommend you install Ubuntu Hardy 8.04 following the steps listed in the howto manual of fakeraid;

That said, we still …
In practice, the fakeraid works by installing the package dmraid. Once installed and loaded the module:

modprobe dm-RAID4-5

RAID MINI UBUNTU

As I wrote before, the kernel sees the disks not only as a normal SATA disks /dev/sda and /dev/sdb but also as one particular device mapped into the directory /dev/mapper, while partitions are shown with a number at the bottom … our controller ddf1 follows the format and label the disk raid that we put in bios was root: why the name of the devices and ‘ddf1_root while the 2 partitions (swap and root) are called, respectively, and ddf1_root1 ddf1_root2

[Intrepid]
If we insert the disk ubuntu intrepid server, which starts in text mode

In recognition of the disc by pressing ctrl + alt + F2 and verify the correct presence of the devices

cd /dev/mapper
ls

and control are ddf1_root

After we turned on the raid, we proceed with the normal graphical installation.

Under the “advanced” that they did not want to install grub (if you forget is not ‘a problem) ..
After the installation is finished reboot the operating system from live cd.

Finished loading, we do not properly assembled the raid because ‘the live and pointed activated the swap partition at the start. So the dmraid failed to properly install the raid.
in fact

sudo dmraid-r

shows the disks but no device in /dev/mapper

to unlock the situation:

sudo swapoff -a
sudo swapon -s
sudo dmraid -ay

Then proceed to the last part of the installation by mounting the partition system’s main operating target and then go to chroot and install the missing packages that also during the final.

sudo mkdir /target
sudo mount /dev/mapper/ddf1_root1/target
sudo mount - bind /dev/target/dev
sudo mount-t proc proc /target/proc
sudo mount-t sysfs sys /target/sys
sudo cp /etc/resolv.conf/target/etc/resolv.conf

sudo chroot /target

apt-get update
apt-get install dmraid
apt-get install grub
mkdir / boot / grub
cp /usr/lib/grub/x86_64-pc/* /boot/grub
or if you have installed the 32-bit
cp / usr/lib/grub/i386-pc/* /boot/grub

install grub on the disk

grub - no-curses
device (hd0) /dev/mapper/ddf1_root
find /boot/grub/stage1
root (hd0, 0)
setup (hd0)
quit

update-grub

nano /boot/grub/menu.lst

and verify that CISIA

# groot=(hd0, 0)

save and restart with a

sudo reboot

The next time we start the system as mentioned earlier by the busybox shell

dmraid-ay
exit

So download and install the package linux-image-2.6.24-23-server and put the new entry in /boot/grub/menu.lst default to automatically run the operating system …

[HARDY]
If instead we started with Hardy we should not use the desktop version, when loading, open a shell and install and activate the software to recognize the raid

1. you need to edit the file /etc/apt/sources.list to enable the universe repositories
then

sudo apt-get update
sudo apt-get install dmraid

or from synaptic. Then load the module and mount the raid

sudo modprobe dm-RAID4-5
sudo dmraid-ay

After we turned on the raid, we proceed with the normal install … possibly following the guide for older versions of ubuntu:

https://help.ubuntu.com/community/FakeRaidHowto # Installing% 20on%% 20older 20releases

Ubuntu Tips and Tricks

October 10th, 2011 No comments

Ubuntu Tips and Tricks

NumLock on by default

If you prefer that the NumLock is activated automatically when you turn on your PC, install the package in the repository numlockx Universe:

 sudo apt-get install numlockx

and edit the file:

 sudo vi /etc/gdm/Init/Default

adding at the beginning:

 if [ -x '/usr/bin/numlockx' ];
 then
         /usr/bin/numlockx on
 fi


Buttons right again

To put the buttons minimize, maximize and close again on the right:

 gconftool-2 --type string --set /apps/metacity/general/button_layout ":minimize,maximize,close"


Empty the Recycle Bin and delete the thumbnail image

To automate emptying the recycle bin (trash) and the elimination of the thumbnail images (thumbnails), to append to the file:

 sudo vi /etc/rc.local

but before any:

 exit 0

the following lines:

 rm-rf /home/*/.thumbnails/*
 rm-rf /home/*/.local/share/Trash

Resource Limit

To avoid problems such as, for example, that aMule closes itself after a while ‘of time and’ on giving messages like:

 Too many open files

add to this file:

 sudo vi /etc/security/limits.conf

lines:

 username soft nofile 8192
 username hard nofile 8192

replacing username with the name of the user you are using. To know what ‘:

 whoami

Another problem could be found using multimedia applications:

 Linux RTC init error in ioctl (rtc_irqp_set 1024): Permission denied

and ‘easily solved by adding at the end of the file:

 sudo vi /etc/rc.local

but before any:

 exit 0

the following line:

 echo 1024 > /proc/sys/dev/rtc/max-user-freq


File System Check

To ensure that the various file system of your PC are only checked once every 6 months, just run this command on each of them (in this example /dev/sdb1):

 sudo tune2fs-c 0-6m /dev/sdb1
 
 tune2fs 1:41:11 (14-Mar-2010)
 Setting maximal mount count to -1
 Between setting interval checks to 15552000 seconds

To see the current setting:

 sudo tune2fs-l /dev/sdb1 | egrep"Maximum mount count | Check interval"
 
 Maximum mount count       : -1
 Check interval            : 15552000 (6 months)


ureadahead main process (…) terminated with status 5

If you boot the PC the error message appears:

ureadahead main process (...) terminated with status 5

and you have /var as separate filesystem, made this change to solve the problem:

 sudo sed -i 's+^start on starting mountall+start on mounted MOUNTPOINT=/var+' /etc/init/ureadahead.conf


Temperature Sensors

With the command

 sensors

and ‘can see the temperature of various components of the PC. If the command returns:

 No sensors found!
 Make sure you loaded all the kernel drivers you need.
 Try to find out sensors-detect Which These are.

proceed by running the command:

 sudo sensors-detect

answering yes to all questions (even the last).

Check the status of the RAID Software

If you have mirrored disks or stripe software, you can controlled from their state with this simple command:

 sudo /sbin/mdadm --detail /dev/md* | egrep "^/dev/md|State : "

that returns an output similar to this:

 /dev/md0:
State : clean
/dev/md1:
State : clean
/dev/md2:
State : active
/dev/md3:
State : clean
/dev/md4:
State : clean

If the state and 'clean or active, there are no problems.

Fedora Directory Server

October 6th, 2011 No comments

NOTE

  • The examples cited in this guide are for FDS 1.1 on Scientific Linux 5.x
  • When installing a few versions with different path or package names may differ.
  • It ‘also strongly recommended that the IP address, IP Name and Hostname of the machine is consistent.

Contents

  • Preparing the System
  • Installing FDS
  • FDS Setup
  • Extension key for INFN
  • Configuring SSL / TLS for the Directory Server
  • Configuring SSL / TLS for the Administration Server
  • Configuration Mapping x509 certificates
  • Configuring SASL / GSSAPI
  • Plugin Configuration Kerberos password backend
  • Configuring Read-Only Replica
  • PADL migration through migrationtools
  • Fedora Management Console

Preparing the System

Change the kernel parameters in /etc/sysctl.conf by putting the lines:

net.ipv4.tcp_keepalive_time = 300
net.ipv4.ip_local_port_range = 1024 65000
fs.file-max = 64000

Recharge sysctl:

sysctl -p

Modify the limits in /etc/security/limits.conf by inserting the line:

*        -        nofile        8192

Make sure the file /etc/pam.d/login is this line:

auth       required     pam_securetty.so

Make log out and log-in to reload the limits.

Create the user fds:

useradd -r -s /bin/false fds

Download and install “J2SE (TM) Runtime Environment 5.0″. In particular http://www.sun.com/java/ available from: http://www.java.com/en/download/manual.jsp#lin

wget 'http://javadl.sun.com/webapps/download/AutoDL?BundleId=23104' -O jre-6u7-linux-x64-rpm.bin
sh jre-6u7-linux-x64-rpm.bin

Once installed jre update-alternatives:

update-alternatives --install /usr/bin/java java /usr/java/latest/bin/java 500
update-alternatives --set java /usr/java/latest/bin/java

 

Installing the packages needed to FDS

yum install ldapjdk svrcore mozldap perl-Mozilla-LDAP xorg-x11-deprecated-libs httpd libstdc++ \
 cyrus-sasl-gssapi openldap-clients libgcj libicu

For 64-bit machines, eliminating the SASL libraries 32bit. ONLY FOR SPECIAL 64bit

NOTE: This step may be required to delete many packages as a dependency, you should accept and delete them.
They are just copies with 32bit libraries of software that will remain in the 64bit version.

yum remove cyrus-sasl.i386 cyrus-sasl-devel.i386 cyrus-sasl-gssapi.i386 cyrus-sasl-plain.i386 cyrus-sasl-lib.i386

 

Installing FDS

Set the YUM repository for Fedora DS. For installation on 32bit machines replace “x86_64” with “i386“.

rpm --import http://download.fedora.redhat.com/pub/fedora/linux/core/6/x86_64/os/RPM-GPG-KEY-fedora
rpm --import http://download.fedora.redhat.com/pub/fedora/linux/extras/RPM-GPG-KEY-Fedora-Extras
rpm --import 'http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xA7B02652'

rpm -ivh http://download.fedora.redhat.com/pub/fedora/linux/extras/6/x86_64/adminutil-1.1.5-1.fc6.x86_64.rpm
rpm -ivh http://download.fedora.redhat.com/pub/fedora/linux/extras/6/x86_64/jss-4.2.5-1.fc6.x86_64.rpm

cd /etc/yum.repos.d
wget -O - http://directory.fedoraproject.org/sources/idmcommon.repo | sed 's/$releasever/6/g' > idmcommon.repo
wget -O - http://directory.fedoraproject.org/sources/dirsrv.repo | sed 's/$releasever/6/g' > dirsrv.repo

Install fedora-ds:

yum install fedora-ds

 

FDS Setup

Run the setup FDS

/usr/sbin/setup-ds-admin.pl

3 Choose the option to customize the installation:

  •  Set up as a user / group “fds”;
  •  Set the root suffix of the form “dc = OFFICE, DC = INFN, dc = com” DNS domain as the site;
  •  Select the port 1500 for the Administration Server;
  •  Everything else can be left at default. (Walkthrough)

Set the starting services at boot FDS

chkconfig on dirsrv
chkconfig-admin on dirsrv

 

Extension key for INFN

Stop FDS:

/etc/init.d/stop dirsrv

Edit the file /etc/dirsrv/slapd-DS-UID/schema/99user.ldif and added at the end:

objectClasses: ( krbprincipal-oid NAME 'krbPrincipal' SUP top STRUCTURAL MUST
 krbPrincipalName X-ORIGIN 'user defined' )
objectClasses: ( CertObject-oid NAME 'CertObject' SUP top STRUCTURAL MUST Cert
 SubjectDN X-ORIGIN 'user defined' )
attributeTypes: ( CertSubjectDN-oid NAME 'CertSubjectDN'  SYNTAX 1.3.6.1.4.1.1
 466.115.121.1.12 X-ORIGIN 'user defined' )
attributeTypes: ( krbPrincipalName-oid NAME 'krbPrincipalName'  SYNTAX 1.3.6.1
 .4.1.1466.115.121.1.15 X-ORIGIN 'user defined' )

Restart FDS:

/etc/init.d/start dirsrv

 

Configuring SSL/TLS for the Directory Server

For a tutorial of the tutorial found AAI server certificates and CA: http://www.lnf.infn.it/dmaselli~/aai/crt/

Convert the server’s private key certificate in pkcs12 format in a temporary file. It is not necessary to set a password.

openssl pkcs12 -export -inkey ds_server_key.pem -in ds_server_crt.pem -out /tmp/crt.p12 -nodes -name 'Server-Cert'

Import the certificate with private key in the DB server of FDS. It ‘must set a password for the DB and remember it. The first password (more confirms) that is sought is that of DB FDS, the second is that if there is one in exports.

cd /etc/dirsrv/slapd-DS-UID/
pk12util -i /tmp/crt.p12 -d .
rm /tmp/crt.p12

where DS-UID and ‘the name of the FDS.

Create a file with the password of the DB Certificate:

cd /etc/dirsrv/slapd-DS-UID
cat > pin.txt <
Internal (Software) Token:PASSWORD
EOF
chown fds:fds pin.txt
chmod 600 pin.txt

Starting the console

fedora-idm-console

In the first tab “Servers and Applications” to expand the tree on the left, click the right mouse button on “Directory Server” and choose “Open

Go Console -> Tasks tab -> Certificate manager -> CA Certs tab (screenshot)
Fedora Server Config

Using the button “Install” to install the CA certificate.

Go Console -> Configuration tab -> Encryption (screenshots)
Fedora Server

Enable the options “Enable SSL for this server” and “Use this Cipher Family: RSA

Make sure that there’s Certificate “Server-Cert“, otherwise leave and return to the console.
Click “Save” and confirm the message.

Restart FDS:

/etc/init.d/restart dirsrv

To configure the client’s default linux ldap (openldap) to enter the CA’s public key in the /etc/openldap/cacerts/ and create a link as follows:

cd /etc/openldap/cacerts/
cp /where/is/the/ca/cert .
for pem in `ls *pem` ; do ln -s $pem `openssl x509 -noout -hash -in $pem`.0 ; done

NOTE: If you want to set or change the password of the DB Certificate of FDS:

cd /etc/dirsrv/slapd-DS-UID
modutil -dbdir . -changepw "NSS Certificate DB"

 

Configuring SSL / TLS for the Administration Server

To configure the Administration Server of Fedora must also know that the host certificates.
Since the name of the node is obviously the same, we share the database of the Directory Server.

Create links to the db directory of the certificates in the configuration of ‘Server Administration.

cd /etc/dirsrv/admin-serv
ln -sf ../slapd-DS-UID/*.db .
cp -pf ../slapd-DS-UID/pin.txt .
sed -i s/Internal/internal/ pin.txt
sed -i "s@NSSPassPhraseDialog  *builtin@NSSPassPhraseDialog  file://///etc/dirsrv/admin-serv/pin.txt@" nss.conf

Restart the Administration Server:

/etc/init.d/restart-admin dirsrv

Starting the console

fedora-idm-console

In the first tab “Servers and Applications” to expand the left tree, right-click on “Server Administration” and choose “Open

Go Console ->; Configuration tab ->; Encryption
Enable the options “Enable SSL for this server” and “Use this Cipher Family: RSA
Make sure that there’s Certificate “Server-Cert“, otherwise leave and return to the console.
Click “Save” and confirm the message.

In the tab “DS Configuration” enable “Secure Connection

In the tab “User DS” select “Set User Directory

Enter HOSTNAME: 636
Enable the “Secure Connection”
Set your base-suffix
Click Save.

Close the console and open that of the Administration Server Directory Server
Go to Configuration tab -> Encryption
Enable the “Use SSL Console”

FDS and restart the Administration Server:

/etc/init.d/dirsrv restart
/etc/init.d/dirsrv-admin restart

From this point the url inserted in the console login window should have https and not http.

 

Configuration Mapping x509 certificates

To enable authentication with x509 certificates, you must configure a mapping between the subject of certificates and entry of the DS.

In the /etc/dirsrv/slapd-DS-UID/certmap.conf we can set the attribute of the DS in which the subject will FDS x509. The only uncommented lines should be:

certmap default         default
default:CmapLdapAttr    certSubjectDN

Restart FDS:

/etc/init.d/dirsrv restart

 

Configuring SASL / GSSAPI

To configure authentication GSSAPI on FDS requires a keytab “ldap/fqdn.del.server.fds REALM.KRB5@“.
Place the keytab in /etc/dirsrv/krb5.keytab fds and ensure that the user can access:

chown fds /etc/dirsrv/krb5.keytab

Edit the file /etc/init.d/dirsrv inserting the definition of the keytab.
In the first lines of the script, after the definition of “fdsRoot” insert:

Export KRB5_KTNAME=/etc/dirsrv/krb5.keytab

Restart FDS.

In the Management Console to define the SASL Mappings:
- In the first tab “Servers and Applications” to expand the tree on the left and click your right mouse button on “Directory Server”
- Will open the Management Console
- Click on the tab “Configuration”
- Click on the name of the server to the left and right click the tab “Mapping SASL”
- Click Add

For example, to configure so that users with a valid ticket “[email protected]” are mapped as “uid=user, ou=People, dc=LNF, dc=INFN , dc=com”, configure as follows:

              Name:  krb5-lnf
Regular Expression:  \(.*\)@LNF.INFN.IT
    Search Base DN:  ou=People, dc=lnf, dc=infn, dc=it
     Search Filter:  (uid=\1)

Where “krb5-LNF” is a simple description.

It ‘possible that the changes are not actual SASL mapping until you restart FDS.

 

Plugin Configuration Kerberos password backend

Coming soon …

 

Configuring Read-Only Replica

Coming soon …

 

PADL migration through migrationtools

And ‘possible to carry out a migration from NIS or LDAP Over PASSWD to the tools available to: http://www.padl.com/OSS/MigrationTools.html

Download and extract migrationtools:

wget http://www.padl.com/download/MigrationTools.tgz
tar -xzvf MigrationTools.tgz
cd MigrationTools-47/

Change the following lines of the file migrate_common.ph:

#$DEFAULT_MAIL_DOMAIN = "padl.com";              # COMMENTARE
$DEFAULT_BASE = "dc=SEDE,dc=infn,dc=it";         # INSERIRE IL PROPRIO BASE DN
#$DEFAULT_MAIL_HOST = "mail.padl.com";           # COMMENTARE
$EXTENDED_SCHEMA = 1;                            # IMPOSTARE A 1

Prepare the passwd and group in two rows.
For example, for NIS:

ypcat passwd > passwd.nis
ypcat group  > group.nis

To convert files in LDIF format for LDAP:

./migrate_passwd.pl passwd.nis passwd.ldif
./migrate_group.pl  group.nis  group.ldif

 

Fedora Management Console

The FDS Management console is the main tool to access the directory server.
To start it:

fedora-idm-console

It ‘always a good idea to login as “admin“.

It ‘can also install it locally to your clients significantly improve the speed.
The only requirement is to have the Java JRE in the system, whether Windows, Linux or Mac

You can find version 1.1 standalone script with “fedora-idm-console” tested for Windows and Linux: http://www.lnf.infn.it/~dmaselli/aai/fds-console-1.1.tar.gz

Mixed network of Windows – Linux

October 6th, 2011 No comments

Cases and situations in common with mixed Windows – Linux network – WINS – PDC.

 

Sample smb.conf for a Primary Domain Controller

Here is an example of a configuration of an NT4 domain PDC that also acts as a Master Browser and WINS Server.

[global]
        workgroup = LAB42
        server string = Samba Server PDC
        log file = /var/log/samba/%m.log
        max log size = 50
        socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
        printcap name = /etc/printcap

# The following is a handy directive to automatically create the machine account to /etc/passwd file when a new computer joins the domain

add machine script = /usr/sbin/useradd -d/dev/null -g machines -s /bin/false -M %u

# The directives that tell the PDC and Samba to allow login on the OST that are part of the domain

        domain master = Yes
        domain logons = Yes

# Directives regarding the functionality of Master Browser

        preferred master = Yes
        os level = 250

# Directives regarding the functionality of Server Wins

        dns proxy = No
        wins support = Yes

        idmap uid = 16777216-33554431
        idmap gid = 16777216-33554431

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

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

[Documents]
        path = /tmp
        guest ok = Yes

[Private]
        comment = Documenti Privati
        path = /var/log
        read only = No

 

Samba as a Primary Domain Controller (PDC)

Samba can perform the activities of PDC, primary domain controller in a Windows network client (or mixed).

The features supported are:

  • Login on the domain (domain logon) for Windows NT/2000/XP clients.
  • User-level security for Windows 9x/ME clients (these clients have no concept of domination, but support log on a domain)
  • Roaming profiles, for users who can log into multiple clients while keeping their environment.
  • Browse lists and master browser
  • Policy NT4 style system
  • Ability to obtain a list of users / groups on the Samba PDC
  • Manage Active Directory (introduced, in part, from version 3.x)

The capabilities are not yet supported:

  • Ability to act as a Domain Controller in an ADS domain (Active Directory)
  •  Use as a BDC (Backup Domain Controller) in a Windows NT4 domain with PDC.

To configure Samba as a PDC in a Windows domain, you must:

  1. Installing Samba on a Linux / Unix (via RPM or source)
  2. Configure smb.conf
  3. Create directories for domain logons and roaming profiles
  4. Add the logins and passwords for users and machines in the domain
  5. Configure the Windows client to join the domain.

The following instructions apply to both version 2 to 3, except for the Directive on the add machine script.

1 – Installing Samba

The installation for a PDC does not require special care compared to a normal installation of Samba using RPM or tar.gz

2 – Configure smb.conf

Let’s see an example of the configuration files of a Samba PDC. Several settings are common to any installation Samba, some are specific to a PDC (domain master = yes, security = user encrypt passwords = yes), others are necessary if you want to support the client running on a script at login (logon scripts [netlogon] share) or the use of roaming profiles (logon path, sharing [profiles]).
Carefully consider the latter option: it has the convenience of separating the use of a single physical machine from a single user (all users can use all the machines), but it involves loading each time you login or synchronization of all the “Documents and Settings ” between Windows client and server, with a potential load on the network is not indifferent and more expected by the user.
Without log files you will act on the local machine, which in turn are then synchronized with the server when logging out.

[Global]
; General Settings (valid on any Samba configuration)

    And intranet workgroup = 'Domain name and / or Workgroups
    netbios name = serverone And 'the name of the Samba server
    server string = Samba PDC - Version% v The server description
    socket options = TCP_NODELAY SO_SNDBUF=8192 SO_RCVBUF=IPTOS_LOWDELAY 8192 recommended default TCP Settings

; Settings for the PDC and master browser

os level = 64 Set the value with which to participate in elections to the Master Browser
preferred master = yes force an election when you start and take part with a greater chance of success
local master = yes Do Samba to participate in elections for the Local Master Browser
The domain master = yes line tells Samba to work with PDC

; Managing users and security

Enforces security = user to authenticate users locally. And ‘necessary on a Samba PDC
Crypt encrypt passwords = yes username and password during authentication: required on a PDC and need to interact seamlessly with Windows NT client or later
domain logons = yes allows Windows clients to log into the domain with the Samba server authenticate
hosts allow = 127.0.0.1 192.168.0.0/255.255.255.0 Allow access only from localhost and from the network 192.168.0.0/24
add machine script = /usr/sbin/useradd-d/dev/null-g machines-s/bin/false-M% u (Only on Samba 3) the system automatically adds the account of a new machine that comes in the domain

; Management logging

log file = /var/log/samba/log.%m defines the location of the log and means to create different log on names of their respective client machines
log level = 2 Set the logging level to 2, displaying all the files read and written
max log size = 50 Sets the maximum size to 50 KB of log files

; User profiles, home directories and netlogon (these configurations in the [global] are ALWAYS adding definitions, respectively [homes], [profiles] and [netlogon] given below

logon home = \\%L\%U\. profile defines the location of the file. profile (for Win9x/ME client) to \\servername\username
logon path = \\%L\profiles\%U defines the position of the profiles directory (WinNT/2K/XP client) to \\servername\profiles\username
logon drive = H: Create the network drive H: to login to Windows clients
logon script = netlogon.bat Specify which script to run on the client at each login. The script is searched in the directory defined in the [netlogon] share

[Homes] Share special, which defines the location of home directories

    comment = Home Directory for each user sharing description
    And browseable = no 'right not to make publicly visible of individual users' home
    writeable = yes Each user must be able to write in his home

[Profiles] Share special where files are written in profile for roaming users. For every login and logout its content is synchronized with the documents folder on the local computer (C:/Documents/username.dominio)

    path = /home/profiles on the Samba server's local directory where you saved the profiles. Here you are, automatically, create users with names sottodirectroy
    writeable = yes Profiles are in sync with the client to login and logout and must be writable
    browseable = no As for the home, including the profiles should not be visible to other users
    create mask = 0600 The mask that creates the files: Full all'owner permits, no permission to other users
    The 0700 directory mask = mask which creates the directory: the owner must also be executable (browsable)

[Netlogon] Special Share which contains the scripts that run on Windows clients to logon to the domain. Must be run on Windows and can be used for various operations of centralized administration (local data backup, antivirus programs or update, the new mapping network shares etc..)

    path = /home/netlogon directory on the server that contains, in a subdirectory with the same name as user login, the script defined by the 'logon script "
    read only = yes Inaccessible These scripts must be read-only ...
    write list = @admin ... except users in the group (@)admin
    browseable = no This is a sharing service that is useless to show to other users

3 – Creating additional directories

It ‘important to create the netlogon directory for the profile defined in smb.conf, and with names and correct permissions.
Based on the example configuration above should do the following on the Samba server (as root):

[root@sambaserver root] # groupadd admin Create the admin group, composed of users who can edit logon scripts. Consider that these scripts are particularly important in terms of security, since that run on Windows client

[root@sambaserver root] # mkdir-m 0775 /home/netlogon Create the directory /home/netlogon, readable and executable by ll users and editable only by owner and ownergroup

[root@sambaserver root] # chown root.admin/home/netlogon You set the directory root as owner and admin for the group (with write permission)

[root@sambaserver root] # mkdir /home/profiles You create a directory for the profiles (the same as defined in smb.conf)

[root@sambaserver root] # chmod 1757/home/profiles You set the sticky bit and make this directory writable by root and its subdirectories can be managed by their users, without the possibility of modifying the other

4 – Add login and password

Manage users in a domain with Samba is not an immediate process and should be considered some fundamental aspects:

- How to use Samba password file /etc/samba/smbpasswd (default) and a row for each user (a domain that is a normal server with authentication). In this file there is a line (with login, encrypted password and other data) for each user.

- For every user in smbpasswd file on their respective member MUST be a normal user files on Unix /etc/passwd. This is because Samba is acting on the local system as a normal Unix process, even if it runs as root, access the filesystem with the permissions of the users as configured.

- When Samba is acting as a PDC, as well as creating a login (either in /etc/samba/smbpasswd in /etc/passwd) for each user, you must create a special login for each machine in the domain. This log, called trust account or computer account has the NetBios name of the computer followed by the dollar sign ($). At the first login from the trust account is created a sort of password that is used to authenticate communications between the PDC and the client and make sure there are other machines that may join the domain with the same NetBios name.

- The management of the log (both for users and for computers, both of which smbpasswd passwd) can be done manually, with the commands below, or automatically through the use of the add user script Directive

- Windows 9x/Me although they can login to a domain, are not structured to be clients of a full-fledged domain because it does not respect the logic of security and trust.

To add a computer account to the domain manually, follow these steps:
[root@sambaserver root] # groupadd machines Create a group for all computer accounts

[root@sambaserver root] # useradd-g machines-d/dev/null-s/bin/false $nameNetBios Adds a login to the system, a member of the machines, without a home directory, without a shell, with the same name as the NetBIOS name machine followed by a $. Note that this account is used to Samba to act on the system, but it is good that it can not be used for normal login.

[root@sambaserver root] # passwd-l $ nomeNetBios will put a lock on the password in order to make it editable and not leave anything but root

[root@sambaserver root] # smbpasswd-a-m nameNetBios You create a new computer account /etc/samba/smbpasswd and set the password. The-a option allows you to create it, if it exists, the-m option indicates that it is a machine account, the NetBios name of the machine should NOT be added followed by $, in this case, when this character is added automatically. No need to remember the password you entered as it is handled directly between PDC and the client domain

If you want to avoid manually add a new account for each machine in the domain, you can try to add, as indicated above, the following line to smb.conf (only valid for Samba 3):

add machine script = /usr /sbin/useradd-d/dev/null-g machines-s/bin/false-M% u

Check the path and the syntax of the command useradd and the group make sure you have already created machines (groupadd machines).

To manually add the user login (not machines) of the domain:

[root@sambaserver root] # useradd foo Adds the user to the /etc/passwd system
[root@sambaserver root] # passwd foo The set password. If the user does not have access to the Unix system, imposed a shell anything in /etc/passwd
[root@sambaserver root] # smbpasswd-a foo foo Adds the user to /etc/samba/smbpasswd and sets the password

NOTE: When you configure a Windows NT/2k/XP to make it part of a domain, you are prompted for an administrator password. In this situation you must use the root login with password, so you must also add the root user smbpasswd:

[root@sambaserver root] # smbpasswd-a root

Note that if by chance you change the root password with passwd and the smbpasswd file is also updated with the password which is the second text, the one in /etc/samba/smbpasswd.

For this reason and others, once a user has created a good thing to make sure that your password on the Unix system is aligned with that used by Samba network. To ensure that a password is changed via Samba also reflects on the /etc/passwd you need to add local configuration lines similar to smb.conf:

unix password sync = yes Sets the synchronization of passwords between Samba and Unix Local
passwd program = /usr/bin/passwd% u command line to change the Unix password. % U is the user’s login
passwd chat = *New*UNIX*password*%n\n*Retype*new*UNIX*password*%n\n*Enter*new*UNIX*password*%n\n*Retype*new*UNIX*password*%n\n* passwd: *all*authentication*tokens*updated*successfully* The procedure for handling requests for matching the output of passwd. Make sure your system is used on the same words

Unfortunately that does not work in reverse: if you change a password with passwd Unix, you must change it by hand with smbpasswd to keep the password synchronized with the Unix Samba passwords.

5 – Configuring Clients

Configuring a Windows system to join a domain, varies depending on the version:
Windows 95/98/ME
- Make sure you installed the “Client for Microsoft Networks” from the network properties
- Ensure that the Client for Microsoft Networks is selected as the primary network protocol (Control Panel -> Network -> Primary Network Logon).
- Go to Control Panel -> Network -> Client for Microsoft Networks -> Properties -> Logon to NT Domain.
- If you have configured smb.conf option “add user script”, select the check box Create a Computer Account, or by hand to create a user on the Samba server as the Windows machine.
- Enter your domain name and click OK.

Windows NT:
- Go to Control Panel -> Network -> Network Identification -> Properties
- Select Domain and enter the name of the domain own the copyright
- Select Create a Computer Account
- When prompted for an administrator password to enter the login and password of root, remember that the root user must be added to smbpasswd.
- You should get a message that welcomes the domain.

Windows 2000:
The procedures are the same as for Windows NT, except that the network settings are found under Control Panel -> System -> Network Identification (or, on the Desktop, right-click the My Computer icon, select Properties, Network Identification tab and click on the Properties button).

Windows XP:
The procedure is more complicated with Windows XP (Microsoft uses complaints to change specifications and implementations of its protocols for interoperability with complicate the alternatives).
Note that only XP Professional Edition can be used to join a domain, Windows XP Home Edition can not join a domain (Samba or Windows based).
- Open the Local Security Policy Editor (Start-> Control Panel-> Tools-PHASE> Local Security Policy-> Local Policies-> Security Options)
- Disable the “Domain member: Digitally encrypt or sign secure channel (always)” (Domain member: Digitally encrypt of Irma secure channel data (always))
- Disable the “Domain member: Disable machine account password changes” (Domain controller: Refuse machine account password changes)
- Disable the “Domain member: Require strong (Windows 2000 or later) session key” (Domain member: Require session key (Windows 2000 or later))
- Download from Samba.org (http://de.samba.org/samba/ftp/docs/Registry/WinXP_SignOrSeal.reg) patch to the registry WinXP_SignOrSeal. To apply the double click. Reg file and answer Yes to questions
- At this point you can join the domain as a Windows NT/2000: Right-click My Computer, select Properties, Computer Name and click on the Edit button uppure and run the Network Identification Wizard.

Linux / Unix
Even Linux systems, of course, can join a domain with a Samba PDC and if the file server, you can configure Samba to allow authentication via the domain.
On smb.conf there must be the following lines:

[Global]
        workgroup =
        netbios name =
        security = DOMAIN
        encrypt passwords = Yes
        password server =
        preferred master = False
        domain master = False

Obviously on the Samba PDC to be created a computer account for our local Samba (as specified in the netbios name) and, in this case, the local computer must first join the domain, a procedure that is comparable to those seen above for Windows clients. On Linux / Unix local enough to write:

smbpasswd-j-r-U root

You have to provide the root password of Samba PDC (remember that the password is stored in the smbpasswd and not in passwd/shadow, in case they are different).

Levels of interoperability between Windows networks and Samba

The possibilities of interoperability between Windows and Samba client and server in a local network for file sharing are varied and can be grouped into two baseline scenarios:
- Windows server with mixed client (Windows, Linux/Unix, MacOS).
- Linux/Unix Samba server with mixed client.

And ‘possible to configure Samba to:
- Act as a Primary Domain Controller (PDC from an NT domain, but not an Active Directory Domain Controller) with a mixed network, including managing profiles and login to Windows machines on the domain. Such an option allows a Linux machine with Samba to perform the same functions of a NT domain PDC.
- To operate as normal File Server for mixed client. The authentication methods may be different depending on the method used and may take several actions on the server and client.
- Work as a Domain Member with the functions of file servers accessible on the basis of the domain login and password. Samba can be either part of an NT domain (Samba 2 or higher) that of an Active Directory (Samba 3 and above)
- Work as a WINS server (or be configured to use a different WINS server). In this case the configuration is simple, fast and effective, does not present any particular problems of compatibility and interoperability.
- Work as a Master Browser in a mixed network.

Samba does NOT allow you to manage instead of a machine as Backup Domain Controller of a Windows PDC, can not be a Backup Browser and can not be a Secondary WINS Server.

On the client side, however, there are no particular problems with using Samba to connect to Windows or Linux server: the remote network share is usually mounted on the local file system and you can normally access with permissions granted.

Integrating Linux in a domain with Winbind WinNT/2000

In this article I want to address a problem a bit ‘but I think particularly interesting: the integration of a Linux (of course equipped with Samba) in an NT domain or a Windows 2000 active directory by using Winbind.

I intend to integrate the possibility that the Linux machine to become part of the actual domain or active directory, but also and above all that the authentication of Linux users (note: Linux users, not users Samba) is obtained from the Windows Primary Domain Controller.

I believe that this possibility is very interesting in those situations where you want to introduce Linux in a network already established on the Windows platform, without having to redefine all users in the new environment.

The context I am referring to is a school network, which is seen in schools that I work professionally, but the proposed solution can be effectively implemented in other environments.

I imagine the objections of the “purists” about the opportunity to “live with the enemy” instead of replacing proprietary products with free software, preferred for ethical reasons, philosophical, educational, economic has often been discussed in the pages of this magazine; the fact is that many times this is not possible, or at least not “immediately”. In some cases you need at least a period of “collaborating” in which to gradually introduce Linux and free software in the meantime to allow for the formation and spread a “culture” profitable enough to operate and manage these tools.

The procedure presented here has been used on a Red Hat 7.3 but it is also applicable to other distributions.
From RedHat version 8.0 allows you to configure your login to a NT domain directly through the command authconfig custom, making these tasks much easier.

SET UP THE TOOLS NEEDED
Winbind is a new software became part of the whole of the Samba suite of tools from version 2.2.2 and is contained in the rpm package samba-common. They include 2 libraries for the Name Service Switch (nsswitch) and Pluggable Authentication Modules (PAM), a utility, and wbinfo a demon winbindd, which allow users to access the Linux machine (and those that provide the services ‘PAM) using account information is already in a Windows Domain Controller.

More specifically provides information on winbindd users and groups nsswitch NT service that is now present in all modern C libraries and allows for data to users, groups and hosts several different types of sources (NIS, DNS, and now also Winbind), the authentication service is ensured, however, by the presence of a suitable PAM module.

We see the steps needed to achieve the desired result (the tests were done on a Linux machine with RedHat 7.3, Samba 2.2.3, part of a network managed by a NT 4.0 PDC named ANDREA:

1) Changes in smb.conf

In the Samba configuration file /etc/samba/smb.conf, add in the [global] section the following guidelines:

; NT domain name
workgroup name = PALLADIUM
; Managing encrypted passwords
encrypt passwords = yes
; Settings on the server PDC
security = domain
password server = *
; Settings for the demon winbindd
winbind separator = +
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind enum users = yes
winbind enum groups = yes
template shell = /bin/bash
template homedir = /home/%D/%U

Some comments on the options that allow you to configure the daemon winbindd:
with winbind separator is the character set that combines the name of NT domain and user name to form the name Linux user, it is recommended to choose a different font than the default “\” that can cause problems as it has a special meaning in the shell, the choice of a “+” should be the best.

winbind uid and winbind gid are used to set the range of user IDs and groups that winbind uses to “remap” windows users and groups on Linux users and groups.

winbind enum users winbind enum groups and used to activate the enumeration of groups and users.

template homedir template shell and allow you to define respectively the shell and the user’s home directory, note the use of “variable samba” domain name =%Q%U=NT and NT user name (in this case the user PALLADIUM + foo will have the home directory /home/PALLADIUM/foo).

2) Changes in nsswitch.conf

In the /etc/nsswitch.conf contains the service configuration nsswitch need to add winbind between the sources of data about users and groups.

So its lines, which usually appear as follows:

passwd: files
group: files
must become:
passwd: files winbind
group: files winbind

The order lists the sources is significant and in this case is appropriately left to the priority in obtaining information for system files (passwd and group).

3) Changes to the configuration file of the WFP

This is the most delicate and “dangerous” operations carried out on the awkward configuration files in /etc/pam.d/, can lead to the impossibility to log in or allow anyone to enter without a password or other similar problems . And ‘so appropriate a copy of the files you are about to change and it is also advisable to keep the reserve open a task as “root” so you can retrace your steps if the tests do not give positive results.

It would also be a discussion about the use of PAM is a very versatile and powerful but it is not possible here.

Thus we see only the changes I’ve made in my tests:
in /etc/pam.d/system-auth I added the line

auth sufficient /usr/lib/security/pam_winbind.so

after the first line already in the auth and I changed the line

auth sufficient/lib/security/pam_unix.so nullok likeauth
in
auth sufficient/lib/security/pam_unix.so nullok likeauth use_first_pass

in /etc/pam.d/login I have added the following two lines, respectively, as the first line as the last line account session required:
account sufficient /lib/security/pam_winbind.so
session required /lib/security/skel = pam_mkhomedir.so /etc/skel/umask = 0022

In particular the last one is very interesting as it is created automatically means that the user’s home directory when it connects for the first time to Linux, referring to the settings described above, when you connects the user + foo PALLADIUM creates the users home directory /home/PALLADIUM/ foo (this of course if and only if the directory / home / PALLADIUM already exists).
A final observation about the change to the file system-auth, its configuration being used in many other PAM configuration files (and not only login) pam_stack through the module, can be a good idea to leave it unchanged, copy and modify the copy of such naming system-auth-winbind. Obviously, references to the file system-auth file contains login will be amended accordingly.

4) Activate and test

Must first enter the Linux machine in NT domain acting on the NT server with the Server Manager on Linux and running the following command:

smbpasswd-j-r ANDREA PALLADIO-U Administrator

If all goes well after entering the password (which has Administrator on NT) you get the message:

Joined domain PALLADIUM

At this point you can turn on smb and winbind services and test the proper functioning of the latter with the commands

wbinfo-u
wbinfo-g

respectively, to obtain the list of users and domain groups.
It ‘can also have a list of all users and groups and those in the domain that those “native” Linux with the commands:

getent passwd
getent group

Finally, you can proceed to the most important evidence that the accreditation on the Linux machine to an existing user in the NT domain, the login user name is written according to the syntax established (in our case “PALLADIUM + foo”) and password of that ‘user in the NT domain.

In my case, to log an error message appears: “[: too many arguments" quite mysterious, are not able to determine the origin even after searching the Internet, however, does not affect in any way the success of the operations carried out by ' user.

It 'also possible to obtain accreditation for other users of services provided that they have support for PAM, for example in the machine under test was active graphical login with gdm and the mechanism to get that worked well in this mode it was necessary to add the file /etc/pam.d/gdm line:

session required/lib/security/skel = pam_mkhomedir.so/etc/skel/umask = 0022

 

CONCLUSIONS
Through the use of Winbind in combination with other tools for Samba administrators have the ability to bring together different platforms using the database of users and groups defined in an existing Windows environment.

This is a further confirmation of the goodness of the choice of GNU/Linux and Free Software in general, at the level of "openness" and possibility of integration between different environments. It 'also confirms the developers of these programs devoted to such topics and the great advantage in this area has free software against proprietary software, which very often is characterized by closed solutions if not "armored" .

Example di smb.conf per un server Linux domain member

[global]
workgroup = LAB42
server string = Samba Server - Si Autentica su PDC esterno
security = domain
password server = 10.42.42.173
log file = /var/log/samba/%m.log
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
printcap name = /etc/printcap
dns proxy = No
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
add user script = /usr/sbin/adduser -d /dev/null -s /bin/false %u
[homes]
comment = Home Directories
read only = No
browseable = No

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

[Documenti]
comment = Documenti Vari
path = /tmp
read only = No

Create a shared folder between Ubuntu and Windows

October 3rd, 2011 No comments

Samba Linux file server

First you need to disable all forms of anti-virus or firewall (including windows) to make the procedure easier, later on, when you have verified that everything works as expected, you can create all your beautiful rules and exceptions to allow the sharing of files between two computers.

To share a folder in Vista should right click on the folder to share and give property-> Folder-Sharing> Advanced Sharing, check the box to share folder, give the name under which it will be visible to the network (in our case the folder will be called “share“, I recommend not to use spaces in the name of the folder) and set all permissions for read and write for all users by clicking on permissions. Now that we have shared the folder “share” will notice that its icon changes. Right Clicking on the folder and selecting Properties-> Sharing, we can see the network path to the folder guise of \\pc_name\folder_name (in my case \\PC-Nibble\share), remember the path network, because what you will allow you to identify your sharing folder.

Now for the configuration of the shared folder on Ubuntu open terminal and install Samba

sudo apt-get install samba

and on additional packages (probably already installed but will still run the command for security)

sudo apt-get install samba smbfs samba-client

Samba is completely handled by the smb.conf configuration file located in the /etc/samba, so for security performed a copy with the command

sudo cp -p /etc/samba/smb.conf /etc/samba/smb.conf.orig

in case your copy of smb.conf is damaged due to incorrect manipulation will simply restore the original command

sudo cp -p /etc/samba/smb.conf.orig /etc/samba/smb.conf

Now we proceed to the creation of the shared folder on linux (for convenience will be created in the home)

sudo mkdir /home/shared

and give it all permissions

sudo chmod 777 /home/shared

Now we set a user who has access to the share

sudo useradd-c "Joe Average"-m-g users-p 123456789 marco

executing this command, we created the user “Joe Average” with group “users”, password “123456789″ and username “mark”.

Now add this user in the Samba user with the command

sudo smbpasswd-a mark

you will be prompted to enter the password for the user “mark” and re-enter to verify: the password that you set the same now that you have entered above (“123456789″ in our case) because the authentication system and Samba must be the same. If we use instead of-the-x option to delete the user from the list of Samba.

Now we have created the shared folder, and you do not we just have to see what we have done to Samba by editing the smb.conf file. Open the file

sudo gedit /etc/samba/smb.conf

go to the end of the “Share Definitions” before the line [printers] and type:

[Linux_Shared_Folder]
path = /home/shared
available = yes
browseable = yes
public = yes
writable = yes
create mask = 0777
directory mask = 0777

in this way will give all access (read write execute) to all network users to the folder /home/shared.

If you want to limit access read-only

[Linux_Shared_Folder_Read_Only]
path = /home/shared
available = yes
browsable = yes
public = yes
writable = yes
create mask = 0777
directory mask = 0777

Now save and close the file and give the smb.conf command

sudo testparm

to see if the smb.conf file is written correctly. Every time you make changes to smb.conf you need to type qualsiesi samba restart with the command

sudo /etc/init.d/samba restart

There are also commands

sudo /etc/init.d/sambastart

and

sudo /etc/init.d/samba stop

We verify that Samba is running again with the command

sudo smbclient-L localhost-U%

and now finally to our colleghiamoci Windows with the command

sudo smbclient //pc_name/folder_name% 123456789-U mark

dividing the% username from the password. Instead of PC name and folder name you have to use the network path that is visible from windows by right clicking shared folder and selecting Properties-> Sharing in the Network path (in my case \\PC-Nibble\share).

If you receive a prompt similar to

Domain=[PC-nibble] OS=[Windows Vista (TM) Home Premium 6001 Service Pack 1] Server=[Windows Vista (TM) Home Premium, 6.0]
smb: \>

means that we can freely browse the shared folder of windows by moving with the command ls, cd etc. .. On Windows, you can do: Come in “Network” panel start and we see our Linux computer, open it and freely browse the directory /home/shared, and if you did everything correctly, you can write and read from windows to linux what qualsiesi the two shared folders. Resources from Linux open-> Connect to Server and select windows server, then write in the server section pc_name/windows_shared_folder (in my case I wrote PC-NIBBLE/share) and insert the Windows credentials to access the share. If by chance you can not make the two communicating computers, probably the workgroup computer is not the same, then open the smb.conf file and change the workgroup in the global section.