Monday, March 10, 2008
Kill nobody /user process
ps aux grep nobody awk '{print $2}' xargs kill -9
Kill user process
ps aux grep apache awk '{print $2}' xargs kill -9
Pure FTP timeouts
How do I automate backup operations in Virtuozzo?
How do I compile some application from sources inside a VPS? It does not seem to have gcc installed.
How do I compile some application from sources inside a VPS? It does not seem to have gcc installed.
# vzpkgadd 101 devel-fc2
How do I add or remove an IP address to a VPS?
# vzctl set 101 --ipadd ipaddress --save
How do I perform some action for all VPSes on the hardware node?
vzlist -o veid -H
# for vps in `vzlist -o veid -H` do
vzctl exec $vps ps ax
done
How do I determine which VPS the process runs on?
# vzpid 10031
Pid VEID Name
10031 113 httpsd
My VPS is hacked / compromised. How do I repair or reinstall it?
There are two ways of restoring a VPS which is hacked or cannot be started for some other reasons. Please make sure that you have created full backup of a VPS before applying any of the following solutions.
Solution #1:
#vzctl recover 101
This command will reinstall OS template and all application templates which were previously installed on a VPS. This action will make it possible to start broken VPS but it does not give any guarantee that all rootkits are removed, if any.
Solution #2:
# vzctl reinstall 101
This command will create brand new VPS on the same OS template as broken one, install the same application templates into it, and restore users' credentials. The contents of the old VPS will be copied into /old directory.
What does [FAIL] warning in vzstat output mean?
Product versions this article applies to:
* Virtuozzo for Linux
Configuration file /etc/vzstat.conf on the hardware node contains thresholds for the following parameters: CPU latency, memory latency, amount of free swapspace, diskspace, etc. You can define your own warning and error levels for any parameter. For example, for swap size:
# Swap free, % limit
# if swap space is heavily used, i.e. swap free < SWAP_FREE_X than
# it's highlighted with yellow (WARN level) or red (ERR level)
SWAP_FREE_WARN=75
SWAP_FREE_ERR=50
How do I regenerate the SSL certificate for VZPP/VZCC (in Service VE)?
APPLIES TO:
- Virtuozzo for Linux
RESOLUTION
You may generate own SSL certificate and install it into Service VE, it will be used by VZPP and VZCC panels.This link http://www.modssl.org/docs/2.8/ssl_faq.html#ToC24 describes how to create certificates.
There is no need to do it inside the Service VE on Virtuozzo node, any machine with OpenSSL installed is good. When you have both certificate and private key, you can either put them to the default files:
/etc/httpd/conf/ssl.key/server.key (private key)
/etc/httpd/conf/ssl.crt/server.crt (certificate)
or you can define your own location for key/certificate pair in the /etc/vzcp/httpd.conf file inside Service VE.
It is needed to restart services for the changes to take effect:
# service httpd restart
# service vzcp restart
Keywords: SSL certificate VZCC VZPP Service VE
Mysql failed to start on :: vps Virtuozzo (cpanel)
Error
-bash-3.00# /etc/init.d/mysql start
Starting MySQL/etc/init.d/mysql: line 159: kill: (11515) - No such process
ERROR!
touch: cannot touch `/var/lock/subsys/mysql': Disk quota exceeded
Fix
Check Inodes of the VPS, increase Inodes.
Then Restart the mysql service
/scripts/restartsrv_mysql
How do I solve vzquota error: "vzquota : (error) Quota on syscall for 101: Device or resource busy"?
# lsof 2> /dev/null egrep '/vz/root/101/vz/private/101'
If there are any processes which hold a directory inside VE root/private area - kill them.
Keywords: vzquota,mount,umount,start,stop,lsof
Source :: http://kb.swsoft.com/en/671
How do I change system time or timezone in a VPS?
How do I compile some application from sources inside a VPS? It does not seem to have gcc installed.
# vzpkgadd 101 devel-fc2
How do I add or remove an IP address to a VPS?
How do I add or remove an IP address to a VPS?
# vzctl set 101 --ipadd 192.168.0.1 --save
What does OFFLINE_MANAGEMENT ('Enable Offline Management') option mean?
# vzctl set 101 --offline_management=yes --save
# vzctl set 101 --offline_management=no --save
My VPS does not start. What should I check?
You don't have valid Virtuozzo license installed. Please check the output of vzlicview command, the status of the license should be ACTIVE. Check /var/log/messages. More information about Virtuozzo licenses can be found in this article.
2. VPS cannot be started because it is locked.
Please follow the instructions from this article.
3. VPS starts but displays an error "/bin/bash: no such file" or similar.
The owner of the VPS could remove some important package such as bash or glibc. The VPS can also be compromised, see below.
4. The VPS starts but Segmentation fault occures very soon after starting.
The VPS can be compromised, please check the corresponding article.
How do I determine that my VPS is hacked / compromised?
Installing mod_evasive
Login too your server and execute
cd /usr/local/src
wget http://www.zdziarski.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz
tar -zxvf mod_evasive_1.10.1.tar.gz
cd mod_evasive
For apache 2.0.x
/usr/sbin/apxs -cia mod_evasive20.c
Then add add this too httpd.conf
DOSHashTableSize 3097
DOSPageCount 6
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600
For apache 1.3.x
usr/local/apache/bin/apxs -cia mod_evasive.c
Then add this too httpd.conf
DOSHashTableSize 3097
DOSPageCount 6
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600
Now just restart apache and the installation is complete.
/etc/init.d/httpd restart
First aid for DDOS attack on port 80
We can use the following steps to recover our server from a DDOS attack on the port 80. To do this you must have logged into the server as a root user.
Step 1 : Install/Configure APF firewall
a) If there are no firewalls installed on the server please install the same,you will get the steps and directions from the following site.
http://www.webhostgear.com/61.html
b) Turn on the antidos option (USE_AD) in the APF conf file
# vi /etc/apf/conf.apf
USE_AD = 1
Step 2 : Install/Configure mod_evasive (for Apache 1.3x)
mod_evasive and mod_dosevasive are the same
a) Install mod_evasive
# wget http://www.zdziarski.com/projects/mo..._1.10.1.tar.gz
# tar -xzvf mod_evasive_1.10.1.tar.gz
# cd mod_evasive
# /usr/local/apache/bin/apxs -i -a -c mod_evasive.c
# /etc/init.d/httpd restart
b) Also include the following lines in the apache conf file
# vi /usr/local/apache/conf/httpd.conf
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
c) Restart the webserver
# /etc/init.d/httpd restart
Step 3 : Install mod_security
Normally we can find/install this module from WHM
WHM >> cPanel >> Addon Modules >> Select "modsecurity " >>save
Step 4 : Blocking IPs
a) Find the IPs those have established a connection with the server
(The following command is the better one to get the IPs, as this will sort the IPsaccording to the number of connections).
netstat -ntu awk '{print $5}' cut -d: -f1 sort uniq -c sort -n
b) Block them using IPTABLES
# iptables -I INPUT -s 218.92.207.28 -j DROP
# service iptables save
# service iptables restart
c) Block them on APF too
# vi /etc/apf/deny_hosts.rules
# service apf restart
Step 5 : Optimizing the httpd.conf file
# vi /usr/local/apache/conf/httpd.conf
Change the bellow options as follows, original values are shown in thebracket.
MaxKeepAliveRequests 50 (100)
KeepAliveTimeout 60 (30)
Also edit the following options too, according to the situation.
Timeout
KeepAliv
MinSpareServers
MaxSpareServers
MaxClients
Step 6 : Install/Configure 3rd party DDOS prevention tools
We can also use the most trusting 3rd party script 'DDoS-Deflate' for preventing DDOS attack effectively.Steps to install this script are as follows.
# wget http://www.inetbase.com/scripts/ddos/install.sh
# sh install.sh
Add the script '/usr/local/ddos/ddos.sh' to cron as follows
# crontab -e*/5 * * * * /usr/local/ddos/ddos.sh >/dev/null 2>&1
Step 7 : Suspend websites
Check the bandwidth usage of all the domains and suspend the high bandwidth consuming domains for a while.
PERMANENT WAY TO FIX THE DDOS ATTACK
As we all know the softwares have its own limitations for preventing against DDOS attack, we can follow these steps to cure it permanently.
1. Ask the NOC for attaching Cisco Guard on the server for 24 hours(Normally this service is free from most NOCs)
2. Attach a hardware firewall for the server.
Hope this will help you in such a situation, for more information kindly refer the following URL:http://forums.cpanel.net/showthread.php?t=66952
Securing tmp
CODE
cd /dev
Create 100MB file for our /tmp partition. If you need more space, make count size larger.
CODE
dd if=/dev/zero of=tmpMnt bs=1024 count=100000
Make an extended filesystem for our tmpMnt file
CODE
mke2fs /dev/tmpMnt
Backup your /tmp dir- I had mysql.sock file that I needed to recreate the symbolic link for. Other programs may use it to store cache files or whatever.
CODE
cd /
CODE
cp -R /tmp /tmp_backup
Mount the new /tmp filesystem with noexec
CODE
mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp
CODE
chmod 0777 /tmp
Copy everything back to new /tmp and remove backup
CODE
cp -R /tmp_backup/* /tmp/
CODE
rm -rf /tmp_backup Now we need to add this to fstab so it mounts automatically on reboots.
CODE
pico -w /etc/fstab You should see something like this:
CODE
/dev/hda3 / ext3 defaults,usrquota 1 1
/dev/hda1 /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda2 swap swap defaults 0 0
At the bottom add
CODE
/dev/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0
(Each space is a tab)
Ctrl + X and Y
Your done- /tmp is now mounted as noexec. You can sleep a little bit safer tonight. I created a hello world c++ and compiled it then moved it to /tmp. Upon trying to run it (even chmod +x'ed), it gives the following error:
CODE
bash: ./a.out: Permission denied
YEAH! /tmp no longer has execute permissions
How to Install Root kit hunter
Then update file property database:
How to disable mod_security for a single account
Having Mod_security enabled for servers prevents commonly used methods to hack websites. Common examples are: outdated software, unpatched and so on.
Symptoms:
If you are receiving access denied message with error code 403 when you check the error logs for any account, it means mod_security rules are triggered.
Minor issues:
It’s applied for the entire server, so all websites are affected, even if there’s a secure software which doesn’t require security restrictions.
Fix :
You can disable the mod_security for that account by adding a simple code in its .htaccess
SecFilterEngine Off
SecFilterScanPOST Off
Solution by
http://howto4life.com/disable-mod_security-for-an-account/12/
How to Edit RDP properties
double click RDP-Tcp
Network Adapter tab
select the required
Web Based MSSQL manager not working
Error
Web Based MSSQL manager is not working when I goes to http://mssql.domain.com after opening when click on any links it is not taking me to login page.
FIX
The problem with SQL admin has been caused by disabled ASP.NET 1.1 as web service extension. I went to IIS > Web service extensions > Allow ASP.NET 1.1. After that I got sql admin working
Detect and Clean a Hacked Server T0rnkit Tutorial
Tornkit is a rootkit, a set of programs that is used by an intruder to have unrestricted access to a compromised Linux system.
Tornkit is also attempts to hide its presence.The t0rn rootkit is designed for speed. By that I mean that it was designed to install quickly on Linux machines. T0rn can do this because it takes very little skill to install and run. All of the binaries that the attacker would need come pre-compiled and the installation process is as simple as ./t0rn. T0rn comes standard with a log cleaner called t0rnsb, a sniffer named t0rns and a log parser called t0rnp.
I am including this so that you all diag and clean up your hacked server.
First of all,
Login to WHM as root
Click Tweak Settings
and please remove the tick fromAllow cPanel users to reset their password via email
Step 1. run chkrootkit, and you will see some INFECTED lines. It will also report that some process are hidden from the ps
chkrootkit
Checking `ifconfig'... INFECTED
Checking `login'... INFECTED
Checking `pstree'... INFECTED
and also:
Checking `lkm'... You have X process hidden for ps command
Warning: Possible LKM Trojan installed
Step 2. /etc/init.d/syslog restart
Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [FAILED]
Starting kernel logger: [ OK ]
Step 3. top
top: Error while loading shared libraries: libncurses.so.4: cannot open shared object file: No such file or directory
Step 4. tail /etc/rc.d/rc.sysinit
# Xntps (NTPv3 daemon) startup..
/usr/sbin/xntps -q
OK.. looks like someone got to your server as well. Since we know what rootkit it is, let us investigate further.
Configuration files
/usr/include/file.h (for file hiding)
/usr/include/proc.h (for ps proc hiding)
/lib/lidps1.so (for pstree hiding)
/usr/include/hosts.h (for netstat and net-hiding)
/usr/include/log.h (for log hiding)/lib/lblip.tk/
(backdoored ssh configuration files are in this directory)
/dev/sdr0 (systems md5 checksum)
/lib/ldd.so {placing tks(sniffer), tkp(parser) and tksb(log cleaner)}
Infected Binaries:
top, ps, pstree lsof, md5sum, dir, login, encrypt,ifconfig,find,ls,slocate,tks,tksb,top,tkpnetstat,pg,syslogd,sz
Infected Librairies:
libproc.a,libproc.so.2.0.6,libproc.so
BackDoor: (located at /lib/lblip.tk)
shdc
shhk.pub
shk
shrs
Now, Lets start the cleaning process:
Step 1.
pico /etc/rc.d/rc.sysinit
remove the lines that show
# Xntps (NTPv3 daemon) startup..
/usr/sbin/xntps -q
Step 2.
reboot the system
WARNING: 2 servers got their kernel removed after reboot.If your's is the case and that is what the DataCenter complains after reboot, please ask them to do the following:
reboot the system using the redhat CD into rescue mode
chroot to the /mnt/sysimage
reinstall kernel packages
that should fix it.
-- since already in resuce mode, perhaps also ask them to --force install the following rpm's
procps*.rpm
psmisc*.rpm
findutils*.rpm
fileutils*.rpm
util-linux*.rpm
net-tools*.rpm
textutils*.rpm
sysklogd*.rpm
Step 3.
After the system is up
cd /lib
rm -rf lblip.tk
Step 4.
remove the configuration files given above.
Step 5.
cat /etc/redhat-release
note down your version of redhat,
then fromwww.rpmfind.netsearch for the following rpm's
procps*.rpm
psmisc*.rpm
findutils*.rpm
fileutils*.rpm
util-linux*.rpm
net-tools*.rpm
textutils*.rpm
sysklogd*.rpm
-- and rpm --force install them
Step 6.
if you see the hosts.h file, it says to hide all IP's from
cat /usr/include/hosts.h
193.60
thus, if you want, you can block all the IP's from 193.60 to your server via iptables.
Step 7.
If all goes OK,please reboot the server, and run chkrootkit again..
Thats it......................
When I check my logs, I see a lot of messages about lame servers. What is that, and how do I fix it?
What is round robin DNS?
What is a reverse DNS record?
How do I change the DNS servers for the network interfaces on my Windows server
How do I setup DNS for my domain?
1. Resolve the DNS using dynamic services on your server. All you need to do is change the A record IP address to point to the IP address where you have setup the domain name. In this case, you can handle this all on your own without needing to contact us.
2. Setup your own nameservers. You can do this through your registrar. This is a bit more complicated and not recommended unless you thoroughly understand DNS.
3. Use our existing nameservers. Add the domain and setup web site for domain in question. Simply go to your registrars control panel and enter in ns1.nameservers.com and ns2.nameservers.com for the domains nameservers. Once this has been completed open a ticket with the domain you wish to enter in to our nameservers. We will also need the IP address to point the domain to.
Highly recommend number 1. It's the easiest of the three and also provides you a point outside of the network to resolve domains. If your registrar is GoDaddy for example, they make it very easy to accomplish number 1 in the list above.
Error : "Fatal, neither ndc or rndc was found on this server"
If when adding a entry for a hostname you get the following error "Fatal, neither ndc or rndc was found on this server"
SSH into your server as and su to root. Then check your /etc/rndc.key file if it should have around 3 lines in it if not you will need to open your named.conf file and copy the 3 lines from the top pertaining to the rndc key they should look like the following:
key "rndc-key" {
algorithm hmac-md5;
secret "xxxxxxxxxxxxxxxxxxxxxxxx";
};
and copy that into the rndc.key file. Once you have done that you will need to
run /scripts/fixndc
once you have done that you should beable to run rndc -s localhost status and see basic information such as:
number of zones: 6
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0
/1000tcp clients: 0
/100server is up and running
If you get a error about file not found in /usr/local/etc/ you will need to create a symbolic like
ln -s /etc/rndc.key /usr/local/etc/rndc.key
Rebuild Apache for Cpanel
First login as 'root' via ssh to your server. Then run the following commands.
cd /scripts
./updatenow
./easyapache
You should then see a menu appear asking you which options you would like built into your apache install. Select number 1 - 4 and then wait a few minutes while the script downloads and rebuilds your apache. Once it has completed it will automatically restart Apache for you and you will then be able to use the new features.