Pages

Sunday, June 30, 2013

How to enable SSH/Shell Access in cPanel

Linux distros include SSH client software by default or it can be easily installed with
'apt-get install openssh-client' or 'yum install openssh-clients' depending on your package manager.

To access your shell with SSH from Linux perform the following steps:

1. Login to cPanel and go to Security > SSH/Shell Access to generate SSH key pair.

2. Click Manage SSH Keys > Generate a New Key. You should use a password to protect the key. You will be asked the password each time you use the key.

3. In Public Keys section click 'Manage Authorization' and 'Authorize'

4. In Private Keys section click Vew/Download then download the key (id_dsa or id_rsa) to your PC.

5. Save it to ~/.ssh directory on your linux machine under a meaningful name to not overwrite your existing keys for example id_dsa.myjavahost

6. Now make sure permissions are correct on the key (one time task) and connect (you will be prompted for the password you setup in step #2):

mypc:~$ chmod 600 .ssh/id_dsa.myjavahost
mypc:~$ ssh -p1033 -i .ssh/id_dsa.myjavahost yourusername@yourservername
Enter passphrase for key '.ssh/id_dsa.myjavahost':

You should be logged in now.

Thursday, June 20, 2013

How To Create Nagios Plugins With Ruby on CentOS 6

Ruby is a popular programming language that allows you to quickly create scripts and install additional libraries (Gems).

We have previously covered how to install Nagios monitoring server on CentOS 6.
This time, we will expand on this idea and create Nagios plugins using Ruby.
These plugins will be running on client servers, and be executed via NRPE.

Step 1 - Install RPMForge Repository and NRPE on client servers
rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum -y install ruby nagios-nrpe
useradd nrpe && chkconfig nrpe on

Step 2 - Create your Ruby Script

How to Install zPanel on CentOS 6

About zPanel


zPanel is a php-based free control panel for windows, mac, and linux servers. The program runs on top of an Apache, MySQL, PHP stack on whichever platform is used. zPanel should be installed on a fresh server, as all of the programs that zPanel requires are set up automatically through their installation process.

Step One—Download the Zipped Installer File.

LOG INTO YOUR SERVER AS THE ROOT USER, do not use sudo.
  1. Download the correct installer for your system:
  2. 64 Bit Installer wget http://www.zvps.co.uk/sites/default/files/downloads/centos-6-3/package/installer-x86_64-install.sh.x.tar.gz
    Or
    32 Bit Installer wget http://www.zvps.co.uk/sites/default/files/downloads/centos-6-3/package/installer-x86-install.sh.x.tar.gz
  3. Unzip the tarball

Monday, June 17, 2013

How to Install mod_cloudflare on a cPanel Server

When using CloudFlare, all of the hits to your web server will come from a CloudFlare IP address. To retrieve the actual IP address from the visitor, you must install mod_cloudflare.

How to Install mod_cloudflare

Connect to your server through SSH and log in as root.

Change directory to /usr/local/src :
cd /usr/local/src
Get the source code for mod_cloudflare:
wget --no-check-certificate https://raw.github.com/cloudflare/mod_cloudflare/master/mod_cloudflare.c
CloudFlare-Tools/master/mod_cloudflare.c
Use the Apache Extension Tool to build and install mod_cloudflare:
apxs -a -i -c mod_cloudflare.c
Restart the Apache HTTP daemon:
service httpd restart
Update the Apache configuration data files:
/usr/local/cpanel/bin/apache_conf_distiller --update
That’s it! From now on, Apache will log the visitors’ IP addresses instead of the CloudFlare IP’s.

Saturday, June 15, 2013

Free cPanel Nginx automated installer Plugin

 nginx is open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. nginxcp cPanel nginx automated installer Plugin which Turbo boost your cPanel server with low resources usage.

Nginx Admin Install instruction:

cd /usr/local/src

wget http://nginxcp.com/latest/nginxadmin.tar

tar xf nginxadmin.tar

cd publicnginx

./nginxinstaller install

Nginx Admin Uninstall instruction:

cd /usr/local/src

wget http://nginxcp.com/latest/nginxadmin.tar

tar xf nginxadmin.tar

cd publicnginx

./nginxinstaller uninstall

If you get any error message “access key doesn’t exist, Go to WHM >> Cluster/Remote Access >> Setup Remote Access Key
Then click Generate New Key  and then to install it.

Please visit http://nginxcp.com/ for information.

cPanel error mysql database size 0MB

You may see the mysql database size as zero in cPanel >> ‘Mysql Databases’ option, though the databases contains tables and data. In order to include the size of the databases while displaying disk usage in cPanel/WHM, perform either of the following steps:

1.  SSH to your server as root and edit the cpanel.config file

 # vi /var/cpanel/cpanel.config
Search for
disk_usage_include_sqldbs=0

and change to
disk_usage_include_sqldbs=1

If the parameter is not present, add it. Save the file and execute the following command:
# /scripts/update_db_cache

OR

2. Login to the WHM, goto Tweak Settings >> ‘SQL’ section and enable the following option:
When displaying disk usage in cpanel/WHM include Postgresql and MySQL.

This issue was fixed on most of times.

PHP script to find php shells

his is a script written by Karen Chun and published under GPL



<?php
/*    lookforbadguys.php         2012-04-09
Copyright (C)2012 Karen Chun, Steven Whitney.
Initially published by http://25yearsofprogramming.com.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
Version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

--Purpose: iterate through server files looking for hacker code snippets, backdoor scripts,
suspicious .htaccess code, suspicious file names.
Suspicious things to search for are stored in easily modifiable lists of regular expressions.

--Tested with PHP 5.2 and 5.3. It might work with earlier versions.
--It is designed for use in either Linux or Windows.
On my system, it runs much slower in Windows.

--Not all things it finds are hacks. Not all hacks are found.
--You should also search manually for weird files (such as .php files) in your image directories,
especially if your .htaccess has redirects or was made executable.
--Some searches are commented out because they can give too many false positives.

----------
CHANGELOG:

--2011-03-08 First published

Disable SSH Direct Root Login

First you need to add new admin user

1,adduser admin

2,passwd admin

Please keep admin password

3, vi /etc/group

Make sure admin user wheel settings

wheel:x:10:root,admin

1. SSH into your server as ‘admin’ and gain root access by su

2. Copy and paste this line to edit the file for SSH logins
vi /etc/ssh/sshd_config

3. Find the line
Protocol 2, 1

4. Uncomment it and change it to look like
Protocol 2

5. Next, find the line
PermitRootLogin yes

6. Uncomment it and make it look like PermitRootLogin no

7. Save the file Ctrl+X then Y then enter

8. Now you can restart SSH
/etc/rc.d/init.d/sshd restart

MySQL downgrade on cPanel server

You know downgrades are not recommended, it’s always best to stick with a newer version and work around whatever issues you have but if you really have to downgrade then this way is pretty easy and always works 99% of the time to be honest.

As always make sure you take BACKUPS of your databases and mysql directory before you continue..

Edit /var/cpanel/cpanel.config and look for the mysql-version line and edit the number to whatever version you need i.e.

mysql-version=5.5

to

mysql-version=5.1

Save it and run the following command:

/scripts/mysqlup –force

After this is done – login to your WHM control panel and run easyeapache and rebuild based on your last profile to connect everything back together.

What is Anonymous FTP and how to enable it

Anonymous FTP allows you and others that you give permission to, to access your “public_ftp” folder.

There are two options available:

1. ftp://ftp.yourdomain.com –This allows others to view, delete, upload and download files directly into your “public_ftp” folder.

2. ftp://ftp.yourdomain.com/incoming –This allows others to upload, view, delete, and download files located only within the public_ftp/incoming folder of your hosting account.

Warning: Anonymous FTP allows anyone access to a restricted area of your site. It is generally safest to not enable Anonymous FTP. If you do enable it, you are responsible for the bandwidth and space used.

To set Anonymous FTP access:

Click on the Ftp Manager button on the home page.

Click on the Anonymous FTP Controls link.

Click on the Allow anonymous access to ftp://ftp.yourdomain.com tick box or the Allow anonymous upload to ftp://ftp.yourdomain.com/incoming tick box. You must click on both tick boxes to enable uploads.

Click on the Save Settings button.

Nameserver IPs not showing in WHM

If the nameserver ips not showing in your  WHM >> Main >> DNS Functions >> Nameserver IPs
In order to fix the issue you need to correct the entries for the name server’s IP in the below two files
1. You can check the entries in the /etc/nameserverips file and it should show the below output
root@server [~]# cat /etc/nameserverips
x.x.x.x=ns1.yourdomain.com
x.x.x.x=ns2.yourdomain.com
And if the entries in the above files are correct then,
2. Check the next file it should show the below output
root@server [~]# cat /var/cpanel/nameserverips.yaml

ns1.yourdomain.com:
x.x.x.x: 1
count: 1
zones: yourdomain.com
ns2.yourdomain.com:
x.x.x.x: 1
count: 1
zones: yourdomain.com
If the nameserver ip entries are missing in your file then make ip changes and restart named service.

Monday, June 10, 2013

How to install installatron cPanel/WHM

This tutorial will give you the commands to run inside SSH, this will install installatron on a cPanel/WHM dedicated or virtual private server.

Step one: wget http://data1.liquenox.com/installatron/installatron_setup.sh
Step two: chmod 755 installatron_setup.sh
Step three: ./installatron_setup.sh -f

When you now login to WHM, you should see installatron inside your plugins area, you should purchase a license from either us, or direct before you can use it to it's full potential

How to install kloxo (LXAdmin)

This will show you and give you the commands to install kloxo, also known as lxadmin.
First of all run the yum update command, simply copy and paste "yum update -y". (This will update your vps system and operating system)

Step one: wget http://download.lxlabs.com/download/kloxo/production/kloxo-install-master.sh (This will download the installation files)

Step two:  sh ./kloxo-install-master.sh (This will start the install)

Step three:  Reboot your vps with the command "reboot"

Once your server is back online, go to: http://your.ip:7777 (For non ssl) or http://your.ip:7778 (For ssl) use the ssl port for the first login, your default user and password will be set as admin & admin.
Then thats it, all done. 

Just setup your dns zones and domains.

How to install Webmin

Webmin is a more advanced server management control panel, offering apache, php, squid and many more.

This is used upon a virtual private server, or a dedicated server, and is an open source platform, with no charges.

Follow the commands below, to install this.

1) wget http://prdownloads.sourceforge.net/webadmin/webmin-1.510-1.noarch.rpm
2) rpm -Uvh webmin-1.510-1.noarch.rpm

Once these are complete, it should say webmin is now installed, you should then go to either your hostname or ip with the port 1000, for example http://127.0.0.1:10000, you can then login with your root information.

Install Cloudflare cPanel

Got a API code from CloudFlare to be a Partner? But you don't know how to install it? Here is a simple to use tutorial.

log into SSH via Putty, Xshell or another Terminal
Log in as root with your password.
1.) cd /usr/local/cpanel
2.) curl https://www.cloudflare.com/downloads/cloudflare.tar.gz > cloudflare.tar.gz
3.) tar -zxf cloudflare.tar.gz
4.) ls -alh (shows you the files in the folder, look for the cloudflare-CloudFlare-CPanel- numbers/leters file)
eg: cloudflare-CloudFlare-CPanel-d03f3b8 (d03f3b8 would be the Unique ID)
5.) cd cloudflare-CloudFlare-CPanel-UNIQUEID/cloudflare/
6.) ./install_cf [API HOST KEY] mod_cf DeluxeWebs
change [API HOST KEY] with the API you got from CloudFlare. Change DeluxeWebs with your company name.
When finished installing.
7.) cd ../../
8.) rm -rf cloudflare-CloudFlare-CPanel-UNIQUEID

Wednesday, June 5, 2013

IP remove from Brute Force Attack database by SSH

Sometimes, because of the Brute Force Attack we are unable to login to WHM if we are using correct details also. Then at that time try using below method.

Login to server via SSH.
Connect with mysql database using mysql command. It will show below output.
root@testserver [/var/log]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 172123
Server version: 5.1.65-cll MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
Then type show databases commands in mysql it will show all databases.

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| cphulkd |
| eximstats |
| horde |
| leechprotect |
| logaholicDB_test |
| modsec |
| mysql |
| roundcube |
+——————–+
9 rows in set (0.00 sec)
Then go to cphulkd database using below command.
mysql> use cphulkd;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
Now, it’s time to show tables.
mysql> show tables;
+——————-+
| Tables_in_cphulkd |
+——————-+
| auths |
| blacklist |
| brutes |
| good_logins |
| logins |
| report |
| whitelist |
+——————-+
7 rows in set (0.00 sec)
You can take backup of tables using below command
mysql>BACKUP TABLE `brutes` TO ‘/path/to/backup/directory’;
Run below command to check your IP is blocked in CPHulk Brute Froce database. Replace xxx.xxx.xxx.xxx with your IP
mysql> SELECT * FROM `brutes` WHERE `IP`=’xxx.xxx.xxx.xxx’;
Run below command to remove IP from database
mysql> DELETE FROM `brutes` WHERE `IP`=’xxx.xxx.xxx.xxx’;
Also, check IP in login table also by running the below command
mysql> SELECT * FROM ‘logins’ WHERE ‘IP’ =’xxx.xxx.xxx.xxx’;
Remove the IP from login table using below command.
mysql> DELETE FROM ‘logins’ WHERE ‘IP’ =’xxx.xxx.xxx.xxx’;
OR
You can use below method to clear brutes and login tables. Please note it will remove all the IP’s from database.
Now empty some tables by giving the below commands.
mysql> DELETE FROM brutes;
Query OK, 60 rows affected (0.00 sec)
mysql> DELETE FROM logins;
Query OK, 34 rows affected (0.00 sec)


9 rows in set (0.00 sec)

Unknown License File Version in cpanel : Failed to get a new license, or part of the update process failed

Sometime while accessing WHM, some links are giving below error.
===============================================

Unknown License File Version (has = 23, needed = 22, length=1554). This means that the system failed to get a new license, or part of the update process failed. If you are the server admin,

===============================================
To resolve this issue follow the below steps

/usr/local/cpanel/cpkeyclt

If above commands work then it’s ok but if it is still show above error then follow the below steps

run the below command to stop cpsrvd service

/usr/local/cpanel/etc/init/stopcpsrvd

then sync the files from cpanel server using below command this will fix your issue.

/usr/local/cpanel/scripts/upcp –sync

How to Install mod_pagespeed in cpanel

Login into your server as “root” and start firing the below commands,
  
cd /usr/local/src
mkdir mod_pagespeed
cd mod_pagespeed
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
rpm2cpio mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv
cp /usr/local/src/mod_pagespeed/usr/lib64/httpd/modules/mod_pagespeed.so /usr/local/apache/modules/
cp /usr/local/src/mod_pagespeed/etc/httpd/conf.d/pagespeed.conf /usr/local/apache/conf/
chmod 755 /usr/local/apache/modules/mod_pagespeed.so
mkdir /var/mod_pagespeed/{cache,files} -p
chown nobody:nobody /var/mod_pagespeed/*

mod_pagespeed has a dependency that you’ll want to enable: mod_deflate (the httpd source directory (httpd-2.2.21) may vary depending on your install):

Command to check mod_pagespeed

Command to check mod_pagespeed is installed in server.
curl -D http://127.0.0.1

You will get below output.


Date: Fri, 07 Sep 2012 21:51:06 GMT
Server: Apache/2.2.3 (CentOS)
X-Mod-Pagespeed: 0.10.22.4-1633

How to install magickwand in linux

First go to the path where you want to download the tar file.

cd /usr/local/src/

Use the below link to download the magickwand tar file.

wget http://www.magickwand.org/download/php/MagickWandForPHP-1.0.9.tar.gz

Extract the file using the below command.

 tar -zxvf MagickWandForPHP-1.0.9.tar.gz

Go inside the extracted folder.

cd MagickWandForPHP-1.0.9

Run the below commands to configure and compile it with PHP

phpize
./configure
make
make install

rpm command cheat sheet for Linux

rpm command cheat sheet for Linux
rpm is a powerful Package Manager for Red Hat, Suse and Fedora Linux. It can be used to build, install, query, verify, update, and remove/erase individual software packages. A Package consists of an archive of files, and package information, including name, version, and description:
SyntaxDescriptionExample(s)
rpm -ivh {rpm-file}Install the packagerpm -ivh mozilla-mail-1.7.5-17.i586.rpm
rpm -ivh –test mozilla-mail-1.7.5-17.i586.rpm
rpm -Uvh {rpm-file}Upgrade packagerpm -Uvh mozilla-mail-1.7.6-12.i586.rpm
rpm -Uvh –test mozilla-mail-1.7.6-12.i586.rpm
rpm -ev {package}Erase/remove/ an installed packagerpm -ev mozilla-mail
rpm -ev –nodeps {package}Erase/remove/ an installed package without checking for dependenciesrpm -ev –nodeps mozilla-mail
rpm -qaDisplay list all installed packagesrpm -qa
rpm -qa | less
rpm -qi {package}Display installed information along with package version and short descriptionrpm -qi mozilla-mail
rpm -qf {/path/to/file}Find out what package a file belongs to i.e. find what package owns the filerpm -qf /etc/passwd
rpm -qf /bin/bash
rpm -qc {pacakge-name}Display list of configuration file(s) for a packagerpm -qc httpd
rpm -qcf {/path/to/file}Display list of configuration files for a commandrpm -qcf /usr/X11R6/bin/xeyes
rpm -qa –lastDisplay list of all recently installed RPMsrpm -qa –last
rpm -qa –last | less
rpm -qpR {.rpm-file}
rpm -qR {package}
Find out what dependencies a rpm file hasrpm -qpR mediawiki-1.4rc1-4.i586.rpm
rpm -qR bash

vi and vim cheat sheet for Linux

Cursor movement
h – move left
j – move down
k – move up
l – move right
w – jump by start of words (punctuation considered words)
W – jump by words (spaces separate words)
e – jump to end of words (punctuation considered words)
E – jump to end of words (no punctuation)
b – jump backward by words (punctuation considered words)
B – jump backward by words (no punctuation)
0 – (zero) start of line
^ – first non-blank character of line
$ – end of line
G – Go To command (prefix with number – 5G goes to line 5)
Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.



Insert Mode – Inserting/Appending text
i – start insert mode at cursor
I – insert at the beginning of the line

Solve PHP Fatal Error: Allowed memory size of 8388608 bytes exhausted (tried…

This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8 MB limit. However, do not fret because this is an easy problem to overcome.


To change the memory limit for one specific script, include a line such as this at the top of the script:

ini_set("memory_limit","12M");

The 12M sets the limit to 12 megabytes (12582912 bytes). If this does not work, keep increasing the memory limit until your script fits or your server squeals for mercy.