Wednesday, January 22, 2014

Change to console in Centos Virtual Box guest

-> "Insert Ctrl-Alt-Del"

"host key"-Del

-> "Insert Ctrl-Alt-Backspace"

"host key"-Backspace

"CTRL-ALT-F1"

"host key"-F1

where "host key" usually is the right CTRL

Mount root files system from Centos 6.5 Live CD

This is useful when we screw things up and we need to fix them from the live cd

pvscan
vgscan
vgchange -ay
lvscan

mount /dev/<volume_group>/<logical_volume> <mount_point>

Disable desktop icons Centos 6.5

Useful for setting up kiosk

gconf-editor

apps -> nautilus -> desktop:
computer_icon_visible unchecked
home_icon_visible unchecked
trash_icon_visible unchecked

Monday, January 20, 2014

Autologin with Centos 6.5

sudo vi /etc/gdm/custom.conf

# Add the below lines

[daemon]
AutomaticLoginEnable=true
AutomaticLogin=username

Saturday, January 18, 2014

Making Fedora 20 more livable

Making Fedora 20 more livable

#Enable the logout button
gsettings set org.gnome.shell always-show-log-out true

#Install gnome-classic-session
sudo yum -y install gnome-classic-session

#Set gnome fallback as default to avoid punishing your users with Gnome3 crap
gsettings set org.gnome.desktop.session session-name gnome-fallback

Setting up a static ip on Centos 6

I was installing a Centos 6.5 guest in a XenServer and since I wanted a static ip for this virtual machine, I ended up without GUI or tool to setup the static ip. So I had to resort to command line fu. Here is the tutorial I followed.

http://www.how2centos.com/centos-configure-network/

Wednesday, January 15, 2014

ltsp Centos 6

http://recallstack.wordpress.com/2013/10/28/instalar-servidor-ltsp-en-centos-6/

xrdp install for Centos 6

Just follow this tutorial

http://platelunch.net/?p=492

Xdmcp Centos 6

Enable xdmcp Centos 6


vi /etc/X11/xdm/Xaccess
#uncomment line with *

vi /etc/X11/xdm/xdm-config
# comment line with requestport 0

vi  /etc/gdm/custom.conf

[security]
DisallowTCP=false
AllowRemoteRoot=true
[xdmcp]
Enable=true
[greeter]
IncludeAll=true

Install PXE install server Centos 6.5

I found that the CentOS wiki was pretty outdated so I wrote this quick guide to setup a PXE install server on Centos 6.5 i386. Change i386 to x86_64 for 64bit installations

#Pseudo-scritp to install Centos 6.5 PXE server

sudo su -l
yum -y install syslinux tftp-server

vi /etc/xinetd/tftp

# Change disable to yes

service xinetd restart

chkconfig xinetd on

# Change according to your ARCH/Version
mkdir -p /tftpboot/images/centos/i386/6.5

#Download iso file for livecd
cd ~/Downloads
wget http://mirror.ovh.net/ftp.centos.org/6.5/os/i386/images/pxeboot/vmlinuz
wget http://mirror.ovh.net/ftp.centos.org/6.5/os/i386/images/pxeboot/initrd.img

# Copy images to directory
cp vmlinuz /var/lib/tftpboot/images/centos/i386/6.5/vmlinuz
cp initrd.img  /var/lib/tftpboot/images/centos/i386/6.5/initrd.img

#Edit dhcpd server

vi /etc/dhcpd/dhcpd.conf

#Add this to your dhcpd.conf file
#Change the below for your server ip

allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server xxx.xxx.xxx.xxx;
filename "/pxelinux.0";

service dhcpd restart

#Copy files into tftpboot
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot
cp /usr/share/syslinux/memdisk /var/lib/tftpboot
cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot
cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot


mkdir /var/lib/tftpboot/pxelinux.cfg

#Create menu
vi /var/lib/tftpboot/pxelinux.cfg/default

#Add the following
DEFAULT linux
PROMPT 100

LABEL linux
  KERNEL images/centos/i386/6.5/vmlinuz
  APPEND initrd=images/centos/i386/6.5/initrd.img

-----------------------
# Install nfs server

yum -y install nfs-utils
vi /etc/idmapd.conf
# line 5: uncomment and change to your domain name
Domain = server.world
vi /etc/exports
# write like below *note
/var/lib/tftpboot 172.16.0.0/16(rw,sync,no_root_squash,no_all_squash)
/etc/rc.d/init.d/rpcbind start 
/etc/rc.d/init.d/nfslock start 
/etc/rc.d/init.d/nfs start 
chkconfig rpcbind on 
chkconfig nfslock on 
chkconfig nfs on 


Friday, December 13, 2013

Installing nagios without samba

# Here is a script to install nagios on Centos 6.5 without the samba dependencies
# since I installed samba4 from source and did not want to install the samba 3.6 that comes with Centos 6
yum -y install nagios nagios-plugins-nrpe nrpe php httpd \
 nagios-common         \
 nagios-plugins         \
 nagios-plugins-breeze     \
 nagios-plugins-by_ssh     \
 nagios-plugins-cluster     \
 nagios-plugins-dhcp        \
 nagios-plugins-dig         \
 nagios-plugins-disk        \
 nagios-plugins-dns         \
 nagios-plugins-dummy       \
 nagios-plugins-file_age    \
 nagios-plugins-flexlm      \
 nagios-plugins-fping       \
 nagios-plugins-game        \
 nagios-plugins-hpjd        \
 nagios-plugins-http        \
 nagios-plugins-icmp        \
 nagios-plugins-ide_smart   \
 nagios-plugins-ircd        \
 nagios-plugins-ldap        \
 nagios-plugins-load        \
 nagios-plugins-log         \
 nagios-plugins-mailq       \
 nagios-plugins-mrtg        \
 nagios-plugins-mrtgtraf    \
 nagios-plugins-mysql       \
 nagios-plugins-nagios      \
 nagios-plugins-nt          \
 nagios-plugins-ntp         \
 nagios-plugins-ntp-perl    \
 nagios-plugins-nwstat      \
 nagios-plugins-oracle      \
 nagios-plugins-overcr      \
 nagios-plugins-perl        \
 nagios-plugins-pgsql       \
 nagios-plugins-ping        \
 nagios-plugins-procs       \
 nagios-plugins-real        \
 nagios-plugins-rpc         \
 nagios-plugins-sensors     \
 nagios-plugins-smtp        \
 nagios-plugins-snmp        \
 nagios-plugins-ssh         \
 nagios-plugins-swap        \
 nagios-plugins-tcp         \
 nagios-plugins-time        \
 nagios-plugins-ups         \
 nagios-plugins-users       \
 nagios-plugins-wave

chkconfig httpd on && chkconfig nagios on
service httpd start && service nagios start

Tuesday, December 10, 2013

Install Samba 4.1.3 on Centos 6.5

# Install dependencies
yum -y remove 'samba*'
yum -y install glibc glibc-devel gcc libacl-devel krb5-workstation krb5-libs pam_krb5
yum -y install 'python*'
yum -y install git git-core
yum -y install gdb
yum -y install 'ctdb*' 'libtdb*' 'python-tdb' 'tdb-tools'
yum -y install 'libtalloc*'
yum -y install pytalloc pytalloc-devel
yum -y install libtevent libtevent-devel
yum -y install 'popt*'
yum -y install ldb-tools pyldb pyldb-devel libldb libldb-devel
yum -y install ncurses ncurses-devel ncurses-libs ncurses-base ncurses-term
yum -y install compat-libtermcap
yum -y install migrationtools
yum -y install perl-Parse-Yapp
yum -y install gamin
yum -y install libaio libaio-devel
yum -y install 'cups*'
yum -y install 'pam*' llibcgroup-pam nss-pam-ldapd passwd sssd-client fprintd-pam PyPAM
yum -y install 'ncurses*'
yum -y install 'libtool-ltdl*'
yum -y install 'isomd5*'
yum -y install 'libgcrypt*' 'python-crypt*'
yum -y install 'libcap*'
yum -y install 'bind-devel' bind-libs bind-utils
yum -y install 'avahi*'
yum -y install 'docbook*'
yum -y install 'libacl*'

#Build samba

cd /root
mkdir samba
cd samba
wget http://ftp.samba.org/pub/samba/samba-4.1.3.tar.gz
tar xvzf samba-4.1.3.tar.gz
cd samba-4.1.3
./configure --enable-debug --enable-selftest
make -j 8
make install
service samba start
chkconfig samba on

# Build and install Bind9

cd /root/
mkdir /root/bind
cd /root/bind
wget https://www.isc.org/downloads/file/bind-9-8-6-p1-tar-gz/?version=tar.gz
tar xvzf index.html\?version\=tar.gz
cd bind-9.8.6-P1
 ./configure --with-gssapi=/usr/include/gssapi --with-dlopen=yes
make -j 8
make install
groupadd -g 25 named
useradd -g named -u 25 -d /var/named -M -s /sbin/nologin named
service named start
chkconfig named on

# Provision domain on your AC DC
/usr/local/samba/bin/samba-tool domain provision --use-rfc2307 --interactive

#to query records, use kerberos login
 /usr/local/samba/bin/samba-tool dns query COMPANY.company.com 
company.com @ ALL

#join domain using uppercase to force kerberos
use :  MYDOMAIN.local.com

Thursday, December 5, 2013

Configuring SELinux to work with rsync in Centos 6

I found that after doing the normal configuration of rsync in Centos 6 you need to add a couple lines of SELinux

sudo setsebool -P allow_rsync_anon_write=1
chcon -t public_content_rw_t /data/

Found here.

Also on the source machine we need the following

sudo setsebool -P rsync_export_all_ro 1
sudo setsebool -P rsync_client 1

Monday, December 2, 2013

Exfat support for Centos 6.4

Follow the instruction to start using the repo, then:
sudo yum install fuse-exfat exfat-utils

Centos 6 + Squid + Filezilla

I was having problems getting Filezilla to work with my Squid/Centos6 server.

I added the following lines to squid.conf

acl ftp proto FTP
always_direct allow ftp

But still was not working, then later came across this solution

acl SSL_ports port 1025-65535 # unregistered ports

And that fixed the whole thing.

This also fixed problems when using Netbeans 7 and git trying to connect to bitbucket.org.

Saturday, November 30, 2013

How to setup proxy autoconfiguration in Centos 6

Here are the steps to add a proxy configuration script to your squid server so that your browser will discover the proxy automagically.

First create the file /var/www/html/wpad.dat on your server. Add the following contents:

function FindProxyForURL(url, host) { return "PROXY mysquid:3128"; } 

This is the simplest javascript code to make it work. You can find more examples here.

If you haven't got httpd, install it

yum install httpd


Add a file wpad.conf in your /etc/httpd/conf.d directory with the contents:

<Directory /var/www/html>
Order deny,allow
Deny from all
# add IP address you allow
Allow from 172.16.1.1/16
</Directory>

Edit the /etc/httpd/conf/httpd.conf file and add the following lines to correctly set the mime type of the .dat file:

AddType application/x-ns-proxy-autoconfig .pac
AddType application/x-ns-proxy-autoconfig .dat

The browser will search for http://wpad/wpad.dat when discovering proxies.

Now the real trick is to add an address record (not an alias, this does not work with all browsers) in your DNS configuration that points to your apache server serving the wpad.dat file

A wpad.my-local-net.com 172.1.1.1 

Make sure to open the firewall for the apache web server serving your wpad.dat file.


How to avoid NetworkManager overwriting resolv.conf in Centos 6 (RHEL 6, Fedora)

This one took me a while to figure out mainly due to conflicting information on the web.

The easiest way to avoid NetworkManager to overwrite your /etc/resolv.conf when getting a dhcp lease is to create a new file /etc/dhcp/dhclient-eth0.conf. For some reason in Centos 6 Network manager will not pick up the /etc/dhcp/dhclient.conf or /etc/dhclient.conf files. Also sometimes it is good to delete the /var/run/nm-dhclient-eth0.conf file since sometimes this file will not be recreated.

Here is my /etc/dhcp/dhclient-eth0.conf file. Change eth0 to the name of your interface if different.

# /etc/dhcp/dhclient-eth0.conf
# Use Google DNS instead of DCHP provided
supersede domain-name-servers 8.8.8.8;
# Correctly set the local domain name
supersede domain-search "mydomain.com";
supersede domain-name "mydomain.com";

The supersede directive will replace the DHCP configuration with your own. If you wish to append or prepend, use the 'append' or 'prepend' directive.

Now regenerate the /etc/resolv.conf file

sudo service NetworkManager restart

Wednesday, November 27, 2013

Install VLC media player on Centos 6.4

# Script to install VLC player on Centos 6.4

#Install the EPEL repository
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

# Install RPMFusion
sudo yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
sudo yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm

# Install VLC
sudo yum -y --enablerepo=remi-test install vlc