Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, December 21, 2008

Installing Ubuntu Using Knoppix CD

I'm trying to avoid the cycle of cleaning viruses and spyware from my nephew Dell Windows Desktop despite having the latest AntiVirus program installed on it. I'm attempting to install Ubuntu using debootstrap on a (Knoppix CD). (additional reference)

- Desktop is a Dell Dimension E510
- Booted using the Knoppix CD. Wireless keyboard works with Knoppix. How convenient.
- Tried to start kwlan to connect to Wireless network. Doesn't work. Oh well, wired lan connection works at least.
- Using fdisk, formatted /dev/sda into /dev/sda1 with ~158GB and /dev/sda2 with remaining ~2GB
- Rebooted to ensure newly created partitions.
- Formatted /dev/sda1 using ext3
# mke2fs -j /dev/sda1
- Set /dev/sda2 as swap

# mkswap /dev/sda2
# sync; sync; sync
# swapon /dev/sda2
- Next, mount the newly formatted hdd.
# mkdir /mnt/ubuntu
# mount /dev/sda1 /mnt/ubuntu
- Setup debootstrap
# mkdir /mnt/ubuntu/work
# cd /mnt/ubuntu/work
# wget http://archive.ubuntu.com/ubuntu/pool/main/d/ \
debootstrap/debootstrap-udeb_0.3.3.0ubuntu2_i386.udeb
# ar -x debootstrap-udeb_0.3.3.0ubuntu2_i386.udeb
# cd /
# zcat /mnt/ubuntu/work/data.tar.gz | tar xv
- This is still missing the latest intrepid scripts. Install those.
# mkdir /mnt/ubuntu/work/tmp
# cd /mnt/ubuntu/work/tmp
# wget http://archive.ubuntu.com/ubuntu/pool/main/d/ \
debootstrap/debootstrap-udeb_1.0.10ubuntu1~intrepid1_all.udeb
# ar -x debootstrap-udeb_1.0.10ubuntu1~intrepid1_all.udeb
# cd /
# zcat /mnt/ubuntu/work/data.tar.gz | tar xv

- I chose the closest Ubuntu archive mirror.
- Run debootstrap

# /usr/sbin/debootstrap --arch i386 intrepid \
/mnt/ubuntu http://www.gtlib.gatech.edu/pub/ubuntu
- After the base system in installed, need to configure it.
# chroot /mnt/ubuntu /bin/bash
- Setup static file system information
# editor /etc/fstab
# /etc/fstab: static file system information.
#
# file system mount point type options dump pass
/dev/sda1 / ext3 defaults 0 1
/dev/sda2 none swap sw 0 0
proc /proc proc defaults 0 0
sys /sys sysfs defaults 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,ro,user,exec 0 0
- Mount all the above filesystems
# mount -a
- /proc didn't mount for some reason. Mounted it manually.
# mount -t proc proc /proc
- ls /proc shows a non-empty directory. Ok.
- Configure keyboard. I didn't change any default choices.
# dpkg-reconfigure console-setup
- Configure networking. I setup only loopback and eth0 from examples in /usr/share/doc/ifupdown/examples
# editor /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
- Setup hostname
# echo ubuntupc > /etc/hostname
- Install kernel and bootloader
# apt-get install linux-image-386
# apt-get install grub
- 'grub-install' doesn't work for whatever reason. This is probably has something to do with the chroot ubuntu system being unable to see /dev/sda. Why? Not sure. I exited chroot and ran grub-install from Knoppix
# exit
# grub-install --root-directory=/mnt/ubuntu /dev/sda1
- chroot again and setup menu.lst. 'update-grub' is supposed to do this automatically. But it didn't work for me. So setting it up manually.
# chroot /mnt/ubuntu /bin/bash
# editor /boot/grub/menu.lst
default 0
timeout 4

title=Ubuntu
root (hd0,0)
kernel /vmlinuz root=/dev/sda1
initrd /initrd.img

- That's it. exit and reboot.
# exit
# reboot
UPDATE: Looks like either I missed a step above or something didn't work, but grub didn't write to MBR. Rebooted to Knoppix CD and installed grub in MBR.
# grub
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
That's it. This time on reboot, Ubuntu booted normally.

UPDATE 2: I setup the GUI desktop for Ubuntu too.
# apt-get install ubuntu-standard
# apt-get install ubuntu-desktop

Sunday, October 19, 2008

Ubuntu on Active Directory

Tried setting up an Ubuntu workstation (ubclient*) on a Windows Active Directory DOMAIN.COM* using Winbind

*values not real (obviously). must use with correct values.

Installed necessary packages

> sudo apt-get install krb5-user
> sudo apt-get install libpam-krb5
> sudo apt-get install krb5-config
> sudo apt-get install libkadm55
> sudo apt-get install winbind
> sudo apt-get install samba
> sudo apt-get install smbfs
> sudo apt-get install smbclient

Made a backup copy of /etc/samba/smb.conf and added the following

[global]
security = ads
realm = DOMAIN.COM
password server = DC.DOMAIN.COM
# note that workgroup is the 'short' domain name
workgroup = LAB
# winbind separator = +
idmap uid = 10000-20000
idmap gid = 10000-20000
winbind enum users = yes
winbind enum groups = yes
template homedir = /home/%D/%U
template shell = /bin/bash
client use spnego = yes
client ntlmv2 auth = yes
encrypt passwords = yes
winbind use default domain = yes
restrict anonymous = 2
DC.DOMAIN.COM* above is a domain controller in DOMAIN.COM*. Since I copy-pasted these values from the manual, I searched for duplicate lines with the same fields and commented them out.

Restart winbind and samba.
sudo /etc/init.d/winbind stop
sudo /etc/init.d/samba restart
sudo /etc/init.d/winbind start

Request a valid Kerberos TGT.
> sudo kinit administrator@DOMAIN.COM
This resulted in an error in my environment.
kinit(v5): KDC reply did not match expectations while getting initial credentials

I continued anyway. Join the workstation to DOMAIN.COM*.
> sudo net ads join -U username
Since the previous command failed, this prompted me for the DOMAIN.COM* administrator* (not local root) password. I got the following reply.
Using short domain name – DOMAIN
Joined 'UBCLIENT' to realm 'DOMAIN.COM'

I checked the Active Directory snap-in on DC.DOMAIN.COM* for the new UBCLIENT* workstation that just joined the domain. It was present. This confirmed the success of the above operation.

I edited
/etc/nsswitch.conf
as follows.

passwd:         compat winbind
group: compat winbind
shadow: compat winbind
I tested the above operations with
wbinfo -u
wbinfo -g
These commands listed the Domain users and groups as expected. Next I edited the file
/etc/pam.d/common-account

as follows
account sufficient       pam_winbind.so
account required pam_unix.so
I edited
/etc/pam.d/common-auth

as follows
auth sufficient pam_winbind.so
auth sufficient pam_unix.so nullok_secure use_first_pass
auth required pam_deny.so
I edited
/etc/pam.d/common-session
as follows

session required pam_unix.so
session required pam_mkhomedir.so umask=0022 skel=/etc/skel
and finally

/etc/pam.d/sudo
as follows
auth sufficient pam_winbind.so
auth sufficient pam_unix.so use_first_pass
auth required pam_deny.so

@include common-account
For the final configuration, I created the domain home directory.
/home/DOMAIN
and added a domain administrator to the sudoers group. I also added a Domain Administrator (domainadmin*) user to the 'admin' group in /etc/group.

To test the final setup I logged in via ssh to ubclient.domain.com as user domainadmin. Command pwd showed that a home directory was created as /home/DOMAIN/domainadmin. I checked to ensure the domainadmin has admin privileges on the local computer.

sudo id

After prompting for the domainadmin's password, it successfully responded as
uid=0(root) gid=0(root) groups=0(root)


That was completely painless to setup. No surprises or failures. I am now able to login into my Ubuntu machine as part of my Active Directory. I wasn't sure about the 'Automatic Kerberos Ticket Refresh' part, but figure it couldn't hurt.

I edited
/etc/samba/smb.conf

as follows

#       winbind separator = +
winbind refresh tickets = yes
idmap uid = 10000-20000


and modified
/etc/pam.d/common-auth

as follows
auth sufficient pam_winbind.so krb5_auth krb5_ccache_type=FILE
auth sufficient pam_unix.so nullok_secure use_first_pass
auth required pam_deny.so


*values not real (obviously). must use with correct values.

Thursday, December 13, 2007

perl xml parser and dependency hell

Was trying to install a perl module from CPAN (Frontier::Daemon) which needed XML::Parser which just wouldn't install. Perl's package manager kept complaining about a missing expat.h file, followed by many lines of errors. yum said expat is up to date. Removing expat (in an effort to reinstall it) removed yum as well. Installing yum wasn't easy. Finally got the rpm for yum to work and installed CentOS's precompiled perl xml parser. perl was satisfied with this and installed Frontier::Daemon without further complaints.

Tuesday, December 11, 2007

When Yum Corrupts Its Own rpm Database

I was using yum the other to update a CentOS 5 server after a long time. It got stuck on a long download and didn't seem to quit even after a long time. Tried ending the process using

> kill pid
> kill -INT pid

This did nothing and the process was still hung. Finally used the trusty but dangerous kill -9 which terminated the process. But this made matters worse. Now yum wouldn't even start. A quick google search led to someone speculating that such forceful killing of the process could have corrupted the rpm database. Per their suggestion,

> rm /var/lib/rpm/__db*
> rpm --rebuilddb
> yum clean all

This fixed everything. Not sure what the above does exactly, but hopefully it's ok. This was not a production box, so it was fine. Yum works!

Tuesday, July 31, 2007

SELinux

I was struggling to install MT4 on a fresh CentOS installation. Building a LAMP Server was a decent guide, but I got stuck at setting up MT4. The 'mt-wizard.cgi' could not find it's own 'mt-static' directory. But the directory would navigate just fine from a browser client. Was MT4-RC1 broken?

I went to the MT::App:Wizard Perl module and edited the function which was testing for {mt-dir}/mt-static/styles.css file, which is how MT determines the location of 'mt-static' folder within its own installation. Adding simple print statements gave the state of the LWP::UserAgent variable.

print STDERR $response->status_line

This output (to the Apache error log of this VirtualHost) an error message similar to "500 Connection refused to {servername}:80. Permission denied". I tried writing my own test perl scripts using LWP::UserAgent and LWP::Simple to verify if either MT4 or Perl themselves weren't broken within the environment.

Finally found /var/log/messages log file that recorded each attempt and access denied. The log file was very helpful. Learnt about SELinux's role over Apache as a security measure. So I tried modifying the local policy as described, but it didn't work. So finally had to change SELinux mode from enforcing to permissive in it's config file at /etc/selinux/config.

SELINUX=permissive

Have to learn more about SELinux and it's role in Linux, Apache, etc.