Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble

NukeNick

Members
  • Content Count

    22
  • Joined

  • Last visited

  • Feedback

    N/A

Posts posted by NukeNick


  1. Σε βήματα, για να αλλάξουμε το CTID ενός VPS που σηκώνεται με openVZ
    (καλό για να κλείνουν τα "κενά" στην αυτόματη αρίθμηση)

    sourcecid=100
    targetcid=101
    vzctl chkpnt ${sourcecid} --dumpfile /tmp/openvz-renumber-dump.${sourcecid}
    mv /etc/vz/conf/${sourcecid}.conf /etc/vz/conf/${targetcid}.conf
    mv /vz/private/${sourcecid} /vz/private/${targetcid}
    mv /vz/root/${sourcecid} /vz/root/${targetcid}
    vzctl restore ${targetcid} --dumpfile /tmp/openvz-renumber-dump.${sourcecid}

     


  2. PROBLEM
    Στην τελευταία αναβάθμιση cPanel, στο δωρεάν plugin του Nginx , παρατηρείται το παρακάτω error:
    wkpzwj.png

    SOLUTION
    Ανοίγουμε το αρχείο /usr/local/cpanel/whostmgr/docroot/cgi/addon_nginx.cgi και κάνουμε comment τη γραμμή  use whmlib;

    • Like 1

  3. Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation.

    A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x.

    Following files/dirs are required for traditional Linux user management:
    * /etc/passwd – contains various pieces of information for each user account

    * /etc/shadow – contains the encrypted password information for user’s accounts and optional the password aging information.

    * /etc/group – defines the groups to which users belong

    * /etc/gshadow – group shadow file (contains the encrypted password for group)

    * /var/spool/mail – Generally user emails are stored here.

    * /home – All Users data is stored here.

    You need to backup all of the above files and directories from old server to new Linux server.

    Commands to type on old Linux system

    First create a tar ball of old uses (old Linux system). Create a directory:
    # mkdir /root/move/
    Setup UID filter limit:
    # export UGIDLIMIT=500
    Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
    # awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
    Copy /etc/group file:
    # awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
    Copy /etc/shadow file:
    # awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
    Copy /etc/gshadow (rarely used):
    # cp /etc/gshadow /root/move/gshadow.mig
    Make a backup of /home and /var/spool/mail dirs:
    # tar -zcvpf /root/move/home.tar.gz /home
    # tar -zcvpf /root/move/mail.tar.gz /var/spool/mail

    Where,

    Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:

    RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf).

    Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).

    You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.

    export UGIDLIMIT=500 – setup UID start limit for normal user account. Set this value as per your Linux distro.

    awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > /root/move/passwd.mig – You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.

    tar -zcvpf /root/move/home.tar.gz /home – Make a backup of users /home dir

    tar -zcvpf /root/move/mail.tar.gz /var/spool/mail – Make a backup of users mail dir

    Use scp or usb pen or tape to copy /root/move to a new Linux system.
    # scp -r /root/move/* user@new.linuxserver.com:/path/to/location

    Commands to type on new Linux system

    First, make a backup of current users and passwords:
    # mkdir /root/newsusers.bak
    # cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

    Now restore passwd and other files in /etc/
    # cd /path/to/location
    # cat passwd.mig >> /etc/passwd
    # cat group.mig >> /etc/group
    # cat shadow.mig >> /etc/shadow
    # /bin/cp gshadow.mig /etc/gshadow

    Please note that you must use >> (append) and not > (create) shell redirection.

    Now copy and extract home.tar.gz to new server /home
    # cd /
    # tar -zxvf /path/to/location/home.tar.gz

    Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail
    # cd /
    # tar -zxvf /path/to/location/mail.tar.gz

    Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:
    # reboot

    Please note that if you are new to Linux perform above commands in a sandbox environment. Above technique can be used to UNIX to UNIX OR UNIX to Linux account migration. You need to make couple of changes but overall the concept remains the same.

     
    • Like 1

  4. To see the total number of mails in the mailing queue:

    Exim count mail in queue

    exim -bpc

     

    Use the following to see which scripts are sending out mail (helps keeping an eye on mailsenders and possible malware):

    List the scripts sending mails and count for each one

    grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n

    To clear the mailing queue:

    Exim clear the mail queue

     

    exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

    Or even better, a “cleaner” approach:

    exim -bp | exiqgrep -i | xargs exim -Mrm

    To clear the Exim mailing statistics:

    Clear Exim Statistics

    cd /var/log
    
    rm -fr exim*.1
    
    rm -fr exim*.2
    
    rm -fr exim*.3
    
    rm -fr exim*.4
    
    rm -fr exim_mainlog ; touch exim_mainlog ; chown mailnull.mail exim_mainlog
    
    rm -fr exim_paniclog ; touch exim_paniclog ; chown mailnull.mail exim_paniclog
    
    rm -fr exim_rejectlog ; touch exim_rejectlog ; chown mailnull.mail exim_rejectlog

    To clean the eximstats MySQL database, enter MySQL with:

    Enter the SQL eximstats DB

    mysql eximstats

    SQL commands (to be used within “mysql>”)

    SQL commands to empty the tables

    delete from sends;
    
    delete from smtp;

     


  5. Today a strange new customer ordered and purchased an unmanaged VPS with 5 IPs from me. Upon further investigation, the user’s order and ID where problematic, as they had been flagged as fraudulent by Maxmind (and by a few hosting companies as well).

    Since there is nothing wrong with selling a VPS to anyone, but obliging him/them to a specific SLA and AUP, we can use iptables of the node in order to limit any kind of malevolent behavior and spamming, thus securing our remaining IP addresses from being blacklisted by major spam-listing organisations.

    IPtables can be configured in the following way:

    iptables -A FORWARD -o eth0 -p tcp -s 10.1.1.1 --dport 25 -m limit --limit 3/minute -m state --state NEW -j ACCEPT
    
    iptables -A FORWARD -o eth0 -p tcp -s 10.1.1.1 --dport 25 -m state --state NEW -j LOG
    
    iptables -A FORWARD -o eth0 -p tcp -s 10.1.1.1 --dport 25 -m state --state NEW -j DROP
    
    
    
    # Limit outgoing mail to 5/hour, plus log and drop anyt surplusing mail. This way we won't cause loss of mail (mailserver will queue/spool and retry), but it will prevent spammers causing too much trouble
    
    iptables -A FORWARD -p tcp --sport 25 --syn -m hashlimit --hashlimit-mode srcip --hashlimit-limit 5/hour --hashlimit-burst 6 -j ACCEPT
    
    iptables -A FORWARD -p tcp --sport 25 --syn -j LOG
    
    iptables -A FORWARD -p tcp --sport 25 --syn -j DROP

     

    • Like 1

  6. Htop is a pretty nice fork of top, which almost makes you forget of using a GUI for simple monitoring tasks. It has pretty nice colours all around your terminal and allows you to have a nice idea of what’s-what, at a glimpse.

    Run these commands for RHEL/CentOS and Fedora  Linux servers

    yum groupinstall "Development Tools"
    
    yum install ncurses ncurses-devel
    
    wget http://hisham.hm/htop/releases/2.0.0/htop-2.0.0.tar.gz
    
    tar xvfvz htop-2.0.0.tar.gz
    
    cd htop-2.0.0
    
    ./configure
    
    make
    
    make install

    Or, run these commands for Debian and Ubuntu Linux servers

    sudo apt-get install build-essential  
    
    sudo apt-get install libncurses5-dev libncursesw5-dev
    
    wget http://hisham.hm/htop/releases/2.0.0/htop-2.0.0.tar.gz
    
    tar xvfvz htop-2.0.0.tar.gz
    
    cd htop-2.0.0
    
    ./configure
    
    make
    
    make install

    If you succesfully followed our instructions, you’ll be able to use htop just by running:

    htop

    As simple as that 

    Why we use the source files directly? Well, most tutorials on the internet, make use of EPEL repository. EPEL repo, has been discontinued, so although installing the repo and then running a simple sudo yum or sudo apt-get command to install htop, there is no guarantee that the version you’ve installed will be upgradable to newer versions.


  7. STEP 1Download the WordPress installation package

    To start the installation process, first you need to download WordPress from it's official download page. We recommend that you always download and install the latest stable version of WordPress.

    wpi7.jpg

    Once you click on the Download button for the latest WordPress version, the installation package will be saved to your hard disk. Locate the installation package that you've just downloaded and extract it to a new folder.

    STEP 2Upload the WordPress Files to Your Server

    Now, you need to upload the extracted files and folders to your web server. The easiest way to upload the installation files is via FTP. For detailed information on how to upload files via FTP, please check our FTP Tutorial.

    IMPORTANT!If you want your WordPress to be the main installation on your account and to be accessible through your main domain (i.e. www.mydomain.com), you need to upload the extracted files to your public_html folder.

    Once the download is complete, extract the archive and upload it to your web hosting account. You can do that via FTP using a client application like Filezilla or via cPanel -> File Manager -> Upload file(s). If you want this WordPress installation to be main for your website, the files should reside in the public_html folder of your account. However, you can always make a subfolder (i.e. public_html/blog) if you want to run only part of your website on WordPress.

    wpi8.jpg

    STEP 3Create a MySQL Database for WordPress to use

    Now, you need to create a MySQL database and assign a user to it with full permissions. For detailed instructions on how to do that, please follow the steps described in our tutorial on How to Create MySQL Username and Database. Once you create your MySQL Database and User, make sure you write down the database name, database username and password you've just created. You will need those for the installation process.

    wpi9.jpg

    STEP 4Go through the installation process

    Now it's time to navigate to your website to start with the installation process. If you have uploaded WordPress in your public_html directory you'll need to go to http://yourdomain.com in your preferred browser. The first thing you will notice is a message, telling you that you don't have a wp-config.php file and you should create one. Just click on the Create a Configuration File button to proceed.

    wpi1.jpg

    On this page you will see a message, asking you to prepare the necessary information for the installation. Since we already have this information, simply press the Go! button.

    wpi2.jpg

    Enter the details for your newly created MySQL database and press the Submit button

    wpi3.jpg

    WordPress will now check if your settings are correct. If you have entered all the necessary information, you will see a confirmation screen. Press the Run the Install button to proceed.

    wpi4.jpg

    On the next screen you will have to enter the information about your administrative username and the title of your new site. In addition, you can specify whether you'd want search engines to index your site or not. Once you fill in that information, press the Install WordPress button. Bear in mind, however, that you should specify a real email address. It can be later used in case you forget your password.

    wpi5.jpg
    THAT'S IT!Your new WordPress application is installed. You can use the Login In button to access your administrative backend and start posting in your new site.
    wpi6.jpg
    • Like 1

  8. 1. Run the following outside the preferred account’s public_html folder:

     

    chown user:nobody /home/USER/public_html

    Run the following inside the preferred account’s public_html folder:

     

    chown -R user:user /home/USER/public_html
    
    find -type f -exec chown user.user {} \;
    
    find -type f -exec chmod 644 {} \;
    
    find -type d -exec chmod 755 {} \;
    Παράθεση

    Where user, is your accounts name

     

    • Like 2

  9. Recently i needed to do some housekeeping on my VPS servers, and in my earlier post CPanel Find /Delete all error log files i was mentioning how to find all error log files on a path (in this case, / ).

    Now i changed some of this command in order to achieve the following.

    • Display the size of each error_log file on the cpanel server
    • Sort the error_log files by size.

    Most of the times, there is a specific script/account misbehaving, so the error_log file keeps on increasin it’s size. This command helps you find the biggest ones by size.

    find / -name error_log -type f -exec du -sh {} \; | sort -n

    You can as well only display the 10 biggest of those error longs, for a quick inquiry on which ones tend to accumulate.

    Want to delete them all?

    find /home/ -type f -name error_log -delete

    ACHTUNG!!! A good admin always reads the error_logs and then decides if they require deletion. 

    • Like 1

  10. Dirty lil' pr1ck, αλλά τη δουλειά του την κάνει. Θα ανεβάσω με μορφοποίηση μόλις προλάβω να ασχοληθώ:

     

    OWNER=$@
    KONTA=`ls -1A /var/cpanel/users/`
    
    count=1
    for x in `echo -n "$KONTA"`;do
      wiersz=`grep -i ^dns /var/cpanel/users/"$x" |cut -d= -f2`
      DOMAIN[$count]=$wiersz
      count=$[$count+1]
      echo "Login:        `echo "$x"`"
    
    
        for i in `echo "${DOMAIN[@]}" | sed  's/ /\n/g'`;do
          for n in ` ls -A /home/"$x"/mail/"$i"/ 2>/dev/null`;do
    
               if   [ "$n" == "cur" ];then echo "$n" > /dev/null
               elif [ "$n" == "new" ];then echo "$n" > /dev/null
               elif [ "$n" == "tmp" ];then echo "$n" > /dev/null
               elif [ "$n" == "" ];then echo "$n" > /dev/null
               else
               echo  "$n"@"$i"
               fi
          done
        done
        echo;echo;
    done

     

    • Like 1

  11. Σου σπάνε τα νεύρα γιατί τα κρατάνε για 10ετίες μέσα στα διεγραμμένα τους? Βγάνε ένα φιρμάνι και τρέχα το, το παρακάτω script ;)
     

    for domainhash in `cat /etc/userdomains | grep "\." | sed 's/ //'`
    do
            read domain user <<<$(echo $domainhash | sed 's/:/ /');
                    find /home/${user}/mail/${domain}/*/.Trash/{cur,new,tmp}/ -type f | xargs -ifile rm -f file
                            find /home/${user}/mail/${domain}/*/.Junk/{cur,new,tmp}/ -type f | xargs -ifile rm -f file
                            done

     

    • Like 2

  12. WordPress – Add SSL to your website

    ssl-based-protection-against-cyber-attacks.png?resize=150%2C150&ssl=1


    Adding an SSL certificate to your website, solves the issues with the latest Google Chrome tactics of labeling your website “Unsecure” and helps you provide a more secure place for your visitors and customers.

    What is an SSL certificate?

    SSL certificates are small data files that digitally bind a cryptographic key to an organization’s details. When installed on a web server, it activates the padlock and the https protocol and allows secure connections from a web server to a browser. This also provides the means for your visitor to visually identify your website as a legitimate website.

    How to install in WordPress

    First of all, an SSL Certificate is not a WordPress addon, but a Server/Domain configuration and installation, that your web hoster should help you to install. Period.
    Having said that, there are many types of SSL certificates that might suite you.

    The main issue that most WordPress admins face, is that having a variety of plugins installed on their wordpress, the will usually get a “Not Secure – Mixed Content” Message instead of the green Secure padlock on their browser address bar.
    This can be easily be fixed using a plugin as well.

    To activate SSL security on your WordPress site, simply follow these steps:
    1. Make sure your hosting provider has implemented an SSL on your domain name (it can be a free SSL Certificate such as Let’s Encrypt, or a paid more secure and recognisable SSL Certificate such as Comodo Wildcard SSL)
    ATTENTION!!! If you are not sure your web host has correctly installed an SSL Certificate for your Domain, Step 2 will render your WordPress unreachable! 
    2. Login to your WordPress Admin area and go to Settings->General. In that page, change WordPress Address (URL) & Site Address (URL) to your https:// accordingly.

    Untitled-1.png?resize=720%2C294&ssl=1


    3. After having activated these, your wp-admin administration page, should be reachable and the green “Secure” padlock should appear. Google Chrome displays the word “Secure” in green colour instead of a green padlock.

    Untitled-1-1.png?resize=282%2C97&ssl=1


    If you receive an “info” icon instead it should mean you actually have Mixed Content on your website (links on your homepage that are https:// and links that aren’t, alltogether).
    This is easily solvable using SSL Insecure Content Fixer plugin

    Untitled-2.png?resize=538%2C376&ssl=1

    This Plugin is quite easy to use. After installing it and activating it, you will find it under SSL Insecure Content Fixer. Its options are quite forthcoming , since you usually need to choose the options in the Fix insecure content section. A good advice is setting this option to “Capture” (most resource using but safest option), and then working your way upwards.

    • Like 2

  13. How to change the hostname of your VPS

    Many times the default or first-choice hostname of your VPS doesn’t please you any more. Changing the hostname is easy if you have ssh access, by following these steps:
    1. Edit your server’s /etc/sysconfig/network file with your preferred text editor (in this case, nano).
      [root@vps ~]# nano /etc/sysconfig/network

      Find the line containing “HOSTNAME=” and add your FQDN hostname.

      HOSTNAME=mynode.domain.com

       

    2. If you utilize internal networking, also change the host associated with the main IP address of your VPS.
      [root@vps ~]# nano /etc/hosts
      127.0.0.1 localhost localhost.localdomain
      123.45.67.89  hostname.domain.com  hostname
      ~
      ~
      -- INSERT -- 2,43-57 ALL

       

    3. Run “hostname” commad, followed by your preferred FQDN hostname:
    4. [root@vps ~]# hostname mynode.domain.com 
      [root@vps ~]# hostname
      mynode.domain.com
      [root@vps ~]#

       

      4. Don’t forget to also restart your network service, for the changes to persist on restart

      /etc/init.d/network restart

       

    And that’s it! You now have a new hostname for your DS/VPS !

    • Like 1

  14. Create the backup using the following command:

    /scripts/pkgacct accountname

     

    If you want to restore the backup on a new Cpanel server, or if the account doesn’t exist on your webserver:

    CPanel Simple account restoration
     
    /scripts/restorepgk <package filename>

     

     

    If you want to restore the backup, use the following command:

    Account full Backup restoration
     
    /usr/local/cpanel/bin/restorepkg --skipaccount cpmove-accountname.tar.gz

     

     

    Important! The command above, restores the accounts using the backup file contents even if the account exists on the web server (–skipaccount)

    • Like 2
×