Wednesday, 22 May 2013

GEOM ELI FULL DISK ENCRYPTION



Boot up with FreeBSD Live CD. Start bsdinstall.

When installation reaches partitioning, select ‘shell’.


Partitioning

# gpart create  –s gpt ada0

1 .Create Boot Block

# gpart add –t freebsd-boot –s 64k ada0
# gpart bootcode  –b /boot/pmbr  –p /boot/gptboot  –i 1 ada0

2 .Create and format Boot partition

# gpart add –t freebsd-ufs –s 256m ada0
# newfs /dev/ada0p2

3. Create and initialize encrypted partition

# gpart add –t freebsd-ufs ada0
# geli init –bl 256 /dev/ada0p3                       (Pass phrase will be prompted.)
# geli attach /dev/ada0p3                   (Pass phrase will be prompted. Device /dev/ada0p3.eli will be created.)
# newfs /dev/ada0p3.eli

4. Mount file systems to /mnt

# mount /dev/ada0p3.eli /mnt
# mkdir /mnt/boot2
# mount /dev/ada0p2 /mnt/boot2

5. Continue Installation

# exit

Once the installation ends, enter into a ‘shell’ to make final changes.


Final Changes

1. Move /boot to /boot2/

# mv /mnt/boot  /mnt/boot2/.


2. Edit loader.conf

# vi /boot2/boot/loader.conf

Add the following lines.

geom_eli_load=”YES”
vfs.root.mountfrom=”ufs:/dev/ada0p3.eli”

3. Edit fstab

Add the following lines

/dev/ada0p2                /boot2              ufs       rw,noatime      1          1
/dev/ada0p3.eli                        /                       ufs       rw,noatime      1          1

TWO NODE PACEMAKER FAIL SAFE CLUSTER WITH FLOATING IP ADDRESS (CentOS 6.3)



On both the nodes

1. Install Pacemaker

yum install pacemaker


2. Create configuration files for COROSYNC

cp /etc/corosync/corosync.conf.example    /etc/corosync/corosync.conf


vi /etc/corosync/service.d/pcmk

service {
        name: pacemaker
        ver: 1
}


3. Install CRMSH

wget -P /etc/yum.repos.d/ http://download.opensuse.org/repositories/network:/ha-clustering/CentOS_CentOS-6/network:ha-clustering.repo

yum install crmsh


4. Start Services

service corosync start

service pacemaker start

chkconfig corosync on

chkconfig pacemaker on





On Primary Node


1. Configure Pacemaker using CRM

crm configure property stonith-enabled=false

crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 params ip=192.168.124.110 cidr_netmask=24 op monitor interval=30s

crm configure primitive postfix ocf:heartbeat:postfix op monitor interval=60s depth="0" timeout="20s"

crm configure property no-quorum-policy=ignore

crm configure rsc_defaults resource-stickiness=100

crm configure order postfix-after-ip mandatory: ClusterIP postfix

crm configure colocation postfixWithIP INFINITY: postfix ClusterIP



The status of the cluster nodes can be checked using the following commands :

crm status

crm resource show

Friday, 29 June 2012

Samba with Windows AD-Integration


Prerequisites
  1. Software
    • Samba > 3.0.20
    • Kerberos MIT/Heimdal
    • ntp
    • often cups-Server
  2. Permissions/Users
    • root-user on the server
    • an AD user with the permission to join AD
Steps
  1. The time between DC's and the Samba server must be in sync
    • use ntp
  2. configure your Kerberos environment kinit must be running fine
  3. configure your smb.conf
    • security = ADS
  4. join into the domain
    • kinit
    • net ads join
  5. start the services
    • nmbd
    • smbd
    • winbindd




Setting Up Kerberos
The first thing to do is to set up the kerberos keys so that they work. Remember that kerberos is time-dependent, so you may have to make sure that the machine time is correct using a protocol like NTP.
Below is a working krb5.conf file.


Note: Letters are case sensitive in this case!!!!!
Without capitalization of your realms and .domain_realm, kerberos won't be able to connect.
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log

[libdefaults]
default_realm = WINDOWS.DOMAIN.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
forwardable = yes

[realms]
WINDOWS.DOMAIN.COM = {
kdc = windows.domain.com
admin_server = windows.domain.com
default_domain = windows.domain.com
}

[domain_realm]
.kerberos.server = WINDOWS.DOMAIN.COM
.windows.domain.com = WINDOWS.DOMAIN.COM

[kdc]
profile = /var/kerberos/krb5kdc/kdc.conf

[appdefaults]
pam = {
debug = false
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}
Save the file. Once the file is saved you can test it with this command:
kinit admin@WINDOWS.DOMAIN.COM.
Remember, again, capitals are important. This should ask you for the password for the user account "admin", and then tell you if you have successfully logged in.
Setting up Samba
Samba is the software that allows you to connect Linux and UNIX clients to a Window's domain in the same way as you would a Windows 2000/XP machine. There are three important components, smbd, nmbd, and winbind, which all use the same configuration file: /etc/samba/smb.conf. Check the example configuration file below:
#GLOBAL PARAMETERS
[global]
workgroup = MIDGARD
realm = WINDOWS.DOMAIN.COM
preferred master = no
server string = Linux Test Machine
security = ADS
encrypt passwords = yes
log level = 3
log file = /var/log/samba/%m
max log size = 50
printcap name = cups
printing = cups
winbind enum users = Yes
winbind enum groups = Yes
winbind use default domain = Yes
winbind nested groups = Yes
winbind separator = +
idmap uid = 600-20000
idmap gid = 600-20000
;template primary group = "Domain Users"
template shell = /bin/bash

[homes]
comment = Home Direcotries
valid users =%S
read only = No
browseable = No

[printers]
comment = All Printers
path = /var/spool/cups
browseable = no
printable = yes
guest ok = yes
A few important switches that might need a bit of explanation.
Now, test the parameters file, and correct any syntax errors, using the command "testparm". It should print out that everything is okay, and a warning about the + sign possibly causing problems with domain joins. This can be safely ignored.
Now to join your machine to the active directory. You will need the user-name and password to a Domain Administrator account to do this. The command you need to join the domain is net ads join -U sadwrn. This should then ask you for a password, and print a domain join notice.
To check that you have succesfully joined the domain, there are several things you can test.
  • net ads join -U administrator Test the connection to the Active Directory.
  • wbinfo -u Should now list all the members of the domain.
  • wbinfo -g Should now list all the groups available in the domain.
  • wbinfo -a username%password checks to see if username using password can connect to the domain.
  • should wbinfo fail to return all groups or users in the active directory, simply increase the idmap gid upper boundary and restart winbind and SMB until all users and groups are produced in the list.
Adding this list to the password list.
The next step is to get the passwd command to check the winbind list for usernames and groups. This is fairly straight forward as it only involves changing one file, /etc/nsswitch.conf and at that fairly minimally. Of course, backup this file before changing it.
passwd: files winbind
shadow: files winbind
group: files winbind

#hosts: db files nisplus nis dns
hosts: files dns wins

# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers: db files
netmasks: files
networks: files dns
protocols: db files
rpc: files
services: files

netgroup: files

publickey: nisplus

automount: files
aliases: files nisplus
Note that the following files (and symlinks) must be present in the system /lib directory:
libnss_winbind.so
libnss_winbind.so.2 -> libnss_winbind.so
libnss_wins.so
libnss_wins.so.2 -> libnss_wins.so


Now all that remains is setting up PAM authentication.
Setting up PAM Authentication for Active Directory.
On RedHat, changing the PAM configuration is as easy as changing one file, the /etc/pam.d/system-auth file. This file is responsible for directing the services that require authentication to the right mechanism to get a response. Change the file as follows:
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required /lib/security/$ISA/pam_env.so
auth sufficient /lib/security/$ISA/pam_unix.so likeauth nullok
auth sufficient /lib/security/$ISA/pam_winbind.so use_first_pass
auth required /lib/security/$ISA/pam_deny.so

account required /lib/security/$ISA/pam_unix.so
account sufficient /lib/security/$ISA/pam_succeed_if.so uid < 100 quiet
account sufficient /lib/security/$ISA/pam_winbind.so use_first_pass
account required /lib/security/$ISA/pam_permit.so

password requisite /lib/security/$ISA/pam_cracklib.so retry=3 type=
password sufficient /lib/security/$ISA/pam_unix.so nullok use_authtok md5 shadow
password sufficient /lib/security/$ISA/pam_winbind.so use_first_pass
password required /lib/security/$ISA/pam_deny.so

session required /lib/security/$ISA/pam_limits.so
session required /lib/security/$ISA/pam_unix.so
session required /lib/security/$ISA/pam_winbind.so use_first_pass
Save the file, and change to another virtual terminal. Try logging in as a Member of the Active Directory. This should work, though you WILL see an error about missing home-directory (don't worry about that, we'll fix that later). If you have had a a previous user account on that machine that matches the log-in from the Active Directory, you will need to comment it out. (comment, not delete, that way you can restore if things go wrong). Check as many users as you can, until you feel comfortable that the mechanism works. ALERT! Remember to ensure that ROOT can still log in.


Authenticating share users and groups against active directory
Yeah, this one took me about a day too.
[Pictures]
comment = Directory for storing pictures
path= /usr/local/pictures
Valid Users =@WINDOWS.DOMAIN.COM+group WINDOWS.DOMAIN.COM+user
writable=yes
browseable=yes
@WINDOWS.DOMAIN.COM+group gives any member of the 'group' on WINDOWS.DOMAIN.COM access to this share.
WINDOWS.DOMAIN.COM+user gives 'user', single user members of WINDOWS.DOMAIN.COM, access to this share.

Configuring Samba
The Samba configuration (tested on 3.0.24) should contain these values:
[global]
passdb backend = tdbsam
idmap backend = ad
idmap uid = 100-20000000
idmap gid = 100-20000000
winbind nss info = rfc2307


RESTART SERVICES smb, nmb and winbind

# service smb restart
# service nmb restart
# service winbind restart


Permissions
AD users and groups may be designated as file and directory owners, and whitespace may be used in group names hwoever must be escaped by backslash. chown, chgrp,setfacl, and getfacl all function with active directory users and groups.


Sunday, 4 March 2012

Oracle 11g Installation (Linux)

Oracle Database 11g Installation   PDF Version
Unpack Files
Unzip the files.
# 11.2.0.1
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
You should now have a single directory called "database" containing installation files.

Hosts File

The"/etc/hosts" file must contain a fully qualified name for the server.
<IP-address>  <fully-qualified-machine-name>  <machine-name>
Pre-requisite Installation Add the following lines in the "/etc/sysctl.conf" file.
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
Run the following command to update the current kernel parameters.
/sbin/sysctl -p
Add the following lines to the "/etc/security/limits.conf" file.
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  4096
oracle              hard    nofile  65536
oracle              soft    stack   10240
Install the following packages.
# From Redhat Enterprise Linux 5 DVD

cd /media/cdrom/Server
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh compat-libstdc++-33*.i386.rpm
rpm -Uvh elfutils-libelf*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgomp-4.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
rpm -Uvh numactl-devel-*
cd /
eject
Create the groups and users required.
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin

useradd -g oinstall -G dba,oper,asmadmin oracle
passwd oracle

Additional Setup

The following setup tasks must be performed regardless of which setupmethod you used previously. Disable secure linux by editing the "/etc/selinux/config" file,making sure the SELINUX flag is set as follows.
SELINUX=disabled
This canbe done using the GUI tool (Applications > System Settings >Security Level). Click on the SELinux tab and disable the feature.The server might need a reboot for the changes to take effect. Create the directories in which the Oracle will be installed.
mkdir -p   /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall   /u01
chmod -R 775   /u01
Login as root and issue the following command.
xhost +
Login as the oracle user and add the following lines at the end of the".bash_profile" file,
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=<Server hostname>; export ORACLE_HOSTNAME
ORACLE_UNQNAME=<db instance name>; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=<db Instance>; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

Installation

Log into the oracle user .Set the DISPLAY environmental variable.
DISPLAY=<machine-name>:0.0; export DISPLAY
Go tothe 'database' directory and start the Oracle Universal Installer (OUI) by issuing.
./runInstaller

This will open the Interface which is self explanatory and will require you to complete the following steps :

Post Installation

Edit the"/etc/oratab" file to set the restart flag for eachinstance to 'Y'.
<Instance name>:/u01/app/oracle/product/11.2.0/db_1:Y