Enforce SSH Connections Alive

Here are a couple of option you have in order to keep the SSH connection alive

$ ssh -o ServerAliveInterval=60 <user>@<ip>

The above will instruct the ‘ssh’ client to sent “alive” packets every 60 seconds.

The following will set the same as default (by adding the option to your ssh client’s configuration file) for each ssh connection.

$echo -e "Host *\n\tServerAliveInterval 60" >> $HOME/.ssh/config

Optimize MySQL tables

Optimize single database table:

mysql> OPTIMIZE TABLE my_table

 

Optimize entire database:

shell# mysqlcheck -op -u root your_database_name

 

Optimize ALL databases:

shell# mysqlcheck -u root -p --auto-repair --check --optimize --all-databases

HOWTO INSTALL RKHUNTER (QUICK GUIDE)

HOWTO INSTALL RKHUNTER (QUICK GUIDE)
1. Download the later rkhunger version from sf.net: http://sourceforge.net/projects/rkhunter/
2. shell# tar -zxvf tar -zxvf rkhunter-1.4.0.tar.gz
3. shell# cd rkhunter-1.4.0
4. shell# ./installer.sh –layout default –install
5. shell# /usr/local/bin/rkhunter –update
6. shell# /usr/local/bin/rkhunter –propupd
7. shell# vi /etc/cron.daily/rkhunter.sh
8: Add the following configuration to rkhunter.sh cron script:

-=-=- cut -=-=-
#!/bin/sh
(
/usr/local/bin/rkhunter –versioncheck
/usr/local/bin/rkhunter –update
/usr/local/bin/rkhunter –cronjob –report-warnings-only
) | /bin/mail -s ‘rkhunter Daily Run (PutYourServerNameHere)’ your@email.here
-=-=- end -=-=-

9. chmod 700 /etc/cron.daily/rkhunter.sh
10. You’re good to go 🙂

Moving solaris zones between different global zones (hosts)

Suppose you have a Solaris zone (ZONENAME) on one host and want to move it on other global zone.

On first server:

1. zoneadm -z ZONENAME halt
2. zoneadm -z ZONENAME detach
3. cd $ZONEHOME
4. tar -cf ../zonename.tar .
5. scp ../zonename.tar user@server2:/$ZONEPATH

On the second server:

1. mkdir $ZONEHOME
2. cd $ZONEHOME
3. tar -xf ../zonename.tar .
4. zonecfg -z ZONENAME
>create -a $ZONEHOME
>exit
5. zoneadm -z ZONENAME attach
6. zoneadm -z ZONENAME boot

You’re good to go 🙂