Various collection of Linux Administration & cPanel notes
# sync all zones on a server to the cluster from userdomains
cat /etc/userdomains | grep -v nobody | cut -d: -f1 | awk ‘{ system(“/scripts/dnscluster synczone “$1 ) }’
# get IPs of any hacks from the process list/lsof
for pid in $(ps auwx | grep zfx |awk ‘{print $2}’); do lsof -p $pid|grep -v domlogs;done|grep TCP
# increase inodes on a VPS
vzctl set X –diskinodes 900000:900000 –save
# resize /tmp/tmpDSK to 1Gb
umount -l /tmp
dd if=/dev/zero of=/usr/tmpDSK bs=1024 count=1024000
mkfs.ext3 /usr/tmpDSK
mount -o loop,rw,noexec,nosuid /usr/tmpDSK /tmp
# force PHP4 handling in .htaccess when both PHP4/PHP5 are compiled
< FilesMatch "\.(php|php5|php4)$" >
SetHandler application/x-httpd-php4
< /FilesMatch >
# SYNC DNS for a zone to the cluster
/scripts/dnscluster synczone $ZONE
# change package restoration dir /home2 or /home2
/etc/wwwacct.conf
# RUN WEB LOGS for all users
ls /home/|cut -d/ -f1 | xargs -n1 -P3 /scripts/runweblogs
# import a dumped db
mysql -u username -p dbname < dumped.sql
# if rsync gives error (some older versions require us to specify use of ssh)
rsync -e ssh
# run after adding/updating IPs
/usr/local/cpanel/cpkeyclt ; /scripts/rebuildippool
# test SSL connection using openssl
openssl s_client -connect hostname:443
# stop backups for vps (from ba svr)
touch /opt/vpnbackup/opfiles/emergency.stopfile
d/l cpanel bkp from another cphost:
wget -r http://domain.com:2082/download?file=backup-archive.tar.gz –user=’name’ –password=’pass’
# cleanups/termination loop
for i in /var/cpanel/suspended/vzc*; do /scripts/killacct $i no < /home/nessa//yes ; done
# whmtop
http://hostname:2087/scripts2/top
# Quick Fix for Broadcast addresses being blocked by firewall:
PKT_SANITY_STUFFED=”0″
# block ip across all containers
for ve in $(vzlist -Ho veid); do vzctl exec $ve ‘/usr/local/sbin/apf -d IP_ADDRESS “brute force pop3″‘;done
# recycle dedicated servers
w/o root: remove user acct, remove logs, run cpanel update, clear history
with root: requires reformat
# security audits
/var/cpanel/accounting
check /tmp for nobody
check /etc/passwd
/var/log/secure
rkhunter
find / -perm +4000 > ~/suids #findsuids
renewing/installing a SSL cert as nobody
add in WHM as nobody, mv /var/cpanel/userdata/nobody/domain*SSL* to /var/cpanel/userdata/CORRECTuser/domain*SSL*
/scripts/rebuildhttpdconf ; service httpd restart
bits to bytes
x kbits / 8
max connections ipv4 (ping timeouts, packet loss)
– see the limit: cat /proc/sys/net/ipv4/ip_conntrack_max
– raise the limit: echo 138304 > /proc/sys/net/ipv4/ip_conntrack_max
mod_security
edit httpd.conf, uncomment user include file
mkdir, edit include file (any.conf)
add: SecRuleEngine Off
Enabling Logging and Statistics for Customers
/scripts/runweblogs/user – shared
WHM -> Statistics Software Configuration – VPS/DED
update web logs for all users on the server
for i in `ls /var/cpanel/users`; do /scripts/runweblogs $i; done
Moving Dedicated Ips
copy /etc/ips
service ipaliases restart
service ipaliases reload
/scripts/rebuildippoolMassmigration.sh
rm -rf /root/cpanel3-skel
ssh-kengen -t dsa / setup keys with new server
change remote server variable IP in script
./massmigration.shEditing Apache Templates and Includes
- edit /var/cpanel/templates/apache2/*
- /scripts/rebuildhttpdconf
- service httpd restart