Reinstalling Grub legacy Linux boot loader

Reinstalling Grub legacy Linux boot loader. If you have accidentally removed Grub or you set up a dual boot and Windows did here is how to restore it.

1. Boot into a Linux live cd.

2. Make the mount point directory.

mkdir /mnt/recovery

3. Mount the partition(s) of the disk your working on.

sudo mount /dev/sdxx /mnt/recovery

(sdxx being the partition to be mounted i.e sda1).

sudo mount /dev/sda1 /mnt/recovery

Install Grub (yum needs to be substituted to the package manager of your distro, yum, aptitude etc. In this example we will use yum.

chroot /mnt/recovery yum install grub -y

4. Reinstall Grub boot loader to the MBR.

sudo grub-install --root-directory=/mnt/recovery /dev/sda

 

Linux, Virtual & Dedicated Servers , ,

Forgotten Plesk mailbox password Linux

Forgotten Plesk mailbox password? Plesk mailbox password recovery guide.

If you have forgotten a Plesk mailbox password on Linux servers you can recover the login details by running the following via SSH.

All to be entered on one line!

mysql psa -uadmin -p`cat /etc/psa/.psa.shadow` -e 'select concat(mail.mail_name,"@",domains.name) as address,accounts.password from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id order by address;'

Email, Linux, Plesk Linux, Virtual & Dedicated Servers ,

Lost Plesk ftp login details. Plesk recover ftp password guide Linux.

Plesk recover ftp password guide.

1. Login to the server using SSH using your SSH client and login to MySQL.

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

2. Run the following MySQL query.

SELECT REPLACE(sys_users.home,’/home/httpd/vhosts/’,”) AS domain, sys_users.login,accounts.password FROM sys_users
LEFT JOIN accounts on sys_users.account_id=accounts.id
ORDER BY sys_users.home ASC;

Unfortunately the width of this page dumps this to multiple lines, however its a one liner!

This will now display a list of all the FTP accounts including the login details.

 

Linux, Plesk Linux, Virtual & Dedicated Servers

Howto disable drweb notification Plesk Linux.

Howto disable drweb notification Plesk Linux.

Modify the following file /etc/drweb/drweb_handler.conf .

Look for and change the following.

[VirusNotifications]
# Enable or disable sending notifications to persons (yes/no)
SenderNotify = no
AdminNotify = no
RcptsNotify = no

Now edit /etc/drweb/drweb32.ini

And set the following.

CronSummary = no

Now restart DrWeb.

service drwebd restart

 

Linux, Plesk Linux, Virtual & Dedicated Servers , , , ,

MySQL query failed Table psa.lockout doesn’t exist

MySQL query failed Table psa.lockout doesn’t exist.

This issue can arise after an upgrade of Plesk 9.5 on attempt at logging in to the Plesk panel, you get the following error.

MySQL query failed: Table ‘psa.lockout’ doesn’t exist

0: common_func.php3:206
db_query(string ‘delete from lockout where (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_wrong)) > (30 * 60)’)
1: cmd_loginup.php:82
createSession(string ‘admin’, string ‘********’)
2: login_up.php3:22

Part of the Plesk login process checks if the account is locked or not and is missing after the upgrade (I suspect security updates).

The fix is simple just recreate the table.

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

mysql> CREATE TABLE `lockout` (
-> `login` varchar(20) character set utf8 NOT NULL default ”,
-> `last_wrong` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-> `attempts` int(11) NOT NULL default ‘1’,
-> PRIMARY KEY (`login`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=latin1
-> ;

Parallels dev could have added this to the login function after the upgrade, but fair play to them or at least benefit of the doubt it could leave the panel open to exploitation If they had. For example brute force and/or MySQL injection. Those kind of exploits could grant a Plesk login and is practically root at web server level but it could also be used to escalate higher privilages.

Linux, MySQL, Plesk Linux, Virtual & Dedicated Servers

MySQL monitoring script Linux. Monitor MySQL daemon.

MySQL monitoring script Linux.

Linux Bash script to monitor MySQL service. Requirements are the nmap port scanner but the script will install it on first run as long as you use yum package manager.

Create the file using nano.

nano -w mysql-monitor.sh

Add the following.

#!/bin/bash

#Author Phil Bond Box Admin www.box-admin.com

packageman=’yum’

#Check if nmap is installed otherwise install (ONLY TESTED WITH YUM)
if [ -e “/usr/bin/nmap” ] ; then
echo “nmap is installed” > /dev/null 2>&1
else
$packageman install nmap -y > /dev/null 2>&1
fi

server=localhost
restartchk=1
attempts=0
service=’mysqld’
servicename=’mysql’
port=’3306′

while [ $restartchk -gt 0 ]; do

portstatus=`nmap $server -p $port | tail -3 | grep $servicename | awk {‘print $2’}`

case $portstatus in
open)echo “Port is responding. $servicename is accepting connections” > /dev/null 2>&1 && let restartchk=0;;
closed)echo “Port is closed. $servicename is not responding” && echo “Attempting to restart Mysqld” && /sbin/service $service restart;;
filtered)echo “Port is filtered. $servicename is not responding” && /sbin/service $service restart;;
esac

if [ $attempts -eq 3 ]; then
echo “Mysqld is failing to start after 3 attempts exiting”
exit 1
fi

let attempts=attempts+1

done

exit 0

Press ctrl+x to exit you will be prompted to save.

Now add the script as a cronjob. Unless you changed your editor variable this will open in Vi.

crontab -e

Now press the insert key on your keyboard to enter edit mode and add the following.

*       0-23    *       *       *       /root/mysql-monitor.sh

Press the esc key on your keyboard to exit edit mode.

Press shift+:

Type wq and hit enter to save.

Now when ever MySQL is not responding you receive an email informing you and the script will attempt to restart the service but will quit if the service fails after 3 attempts. The destination email will be the email set for your cronjobs.

Bash Scripting, Linux, MySQL , ,

The webpage at https://yourip:11444/relay might be temporarily down or it may have moved permanently to a new web address.

The webpage at https://yourip:11444/relay might be temporarily down or it may have moved permanently to a new web address.

You mainly see this error in Plesk 9.x if you are trying to access it using Google Chrome. The reason you see this is becuse of the way it handles Plesks SSO or “single sign on”.

SSO is mainly used to provide intergration with Parrallels Plesk Billing by providing you with a single login between products without having relogin everytime you switch between products.

There are two fixes for this. Either you upgrade to the latest Plesk build, Plesk 10.x or you disable SSO. The easyest is to disable it.

To disable login to your Plesk server via SSH and run the command:

/usr/local/psa/bin/sso --disable

To renable SSO run:

/usr/local/psa/bin/sso --enable

 

Linux, Plesk Linux, Virtual & Dedicated Servers , ,

Installing Mcrypt extension PHP Linux from source

Installing mcrypt Linux howto guide. Guide for Red Hat 5 CentOS 5 using PHP53 packages.

Install the PHP development packages.

yum install php53-devel

Install the Mcrypt development packages.

yum install libmcrypt-devel

Download PHP.

wget http://www.php.net/get/php-5.3.3.tar.gz/from/uk.php.net/mirror

Extract the PHP archive and cd into the Mcrypt directory.

tar -zxf php-5.3.3.tar.gz && cd php-5.3.3/ext/mcrypt/

Install The PHP Mcrypt module.

phpize

aclocal

./configure

make

make test

make install

Add the Mcrypt extension to the PHP configuration.

echo “extension=mcrypt.so” > /etc/php.d/mcrypt.ini

Restart Apache.

service httpd restart

Other versions of PHP can be found in the downloads section.

 

 

Linux, PHP, Virtual & Dedicated Servers , , ,

Plesk ftp not working Linux.

Plesk ftp not working Linux?

If you are unable to connect to ftp on your server, xinetd failing to start the service due to being unable to resolve the hostname is one possible cause.

Attempt a connection to the ftp daemon.

[root@linserv01 ~]# ftp localhost
Connected to localhost.localdomain.
421 Service not available, remote server has closed connection
ftp>

Check the system messages log for errors

tail - f /var/log/messages

Here we see the error that ProFTPD is unable to resolve the servers hostname.

Feb 21 07:22:03 linserv01 xinetd[1614]: START: ftp pid=7454 from=127.0.0.1
Feb 21 07:22:03 linserv01 proftpd[7454]: warning: unable to determine IP address of ‘linserv01’
Feb 21 07:22:03 linserv01 proftpd[7454]: error: no valid servers configured
Feb 21 07:22:03 linserv01 proftpd[7454]: Fatal: error processing configuration file ‘/etc/proftpd.conf’
Feb 21 07:22:03 linserv01 xinetd[1614]: EXIT: ftp status=1 pid=7454 duration=0(sec)

Add the hostname to /etc/hosts

nano -w /etc/hosts

Add

hostname ipaddress

i.e

linserv01 192.128.125.161

Now press ctrl +x to exit and save.

[root@linserv01 ~]# ftp localhost
Connected to localhost.localdomain.
220 ProFTPD 1.3.1 Server (ProFTPD) [127.0.0.1]
500 AUTH not understood
500 AUTH not understood
KERBEROS_V4 rejected as an authentication type
Name (localhost:root):

Now your Plesk ftp is working.

FTP, Linux, Plesk Linux, Virtual & Dedicated Servers , , , , , , ,

Howto remove Dr Web Plesk Linux

Howto remove Dr Web Plesk on Linux servers.

Red Hat based package managers.

rpm -qa | grep drweb | xargs rpm -e

or,

yum remove packages listed by rpm -qa | grep drweb.

Debian based package managers.

dpkg -l | grep drweb | awk {‘print $2;’} | xargs aptitude remove -y

or,

aptitude remove the packages listed by dpkg -l | grep drweb

Linux, Plesk Linux, Virtual & Dedicated Servers , , , , , ,