Sunday, February 26, 2017

cPanel manual migration

pkg account:

for i in `cat 1.txt`;do /scripts/pkgacct $i; mv /home/cpmove-$i.tar.gz /home/Migration/;done

restore pkg:

for x in $(cat 1.txt); do /scripts/restorepkg /home/cpmove-$x.tar.gz; done;

Finding spam on cPanel server

You can find the spam on cPanel server using below script. It will help you to find exact location of spam mail script and user sending spam.


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


cPanel backend files

/usr/local/cpanel : Cpanel directory
/usr/local/cpanel/3rdparty/ : tools like fantastico, mailman files are located here
/usr/local/cpanel/addons/ : AdvancedGuestBook, phpBB etc
/usr/local/cpanel/base/ : phpmyadmin, squirrelmail, skins, webmail etc
/usr/local/cpanel/bin/ : cpanel binaries
/usr/local/cpanel/cgi-sys/ : cgi files like cgiemail, formmail.cgi, formmail.pl etc
/usr/local/cpanel/logs/ : cpanel access log and error log
/usr/local/cpanel/whostmgr/ : whm related files
WHM related files
/etc/httpd/conf/httpd.conf – apache configuration file
/etc/exim.conf – mail server configuration file
/etc/named.conf – name server (named) configuration file
/etc/proftpd.conf – proftpd server configuration file
/etc/pure-ftpd.conf – pure-ftpd server configuration file
/etc/valiases/domainname – catchall and forwarders are set here
/etc/vfilters/domainname – email filters are set here
/etc/userdomains all domains are listed here – addons, parked,subdomains along with their usernames
/etc/localdomains – exim related file – all domains should be listed here to
be able to send mails
/var/cpanel/users/username – cpanel user file
/var/cpanel/cpanel.config – cpanel configuration file ( Tweak Settings )
/etc/sysconfig/network – Networking Setup
/etc/resolv.conf – Networking Setup–> Resolver Configuration
/etc/nameserverips – Networking Setup–> Nameserver IPs
/var/cpanel/resellers -  For addpkg, etc permissions for resellers.
/etc/chkserv.d – Main >> Service Configuration >> Service Manager
/var/run/chkservd – Main >> Server Status >> Service Status
/var/log/dcpumon-  top log process
/root/cpanel3-skel – skel directory. Eg: public_ftp, public_html. (Account
Functions–>Skeleton Directory )
/etc/wwwacct.conf – account creation defaults file in WHM (Basic cPanel/WHM
Setup)
/etc/cpupdate.conf – Update Config
/etc//etc/clamav.conf – clamav (antivirus configuration file )
/etc/my.cnf – mysql configuration file
/usr/local/Zend/etc/php.ini OR /usr/local/lib/php.ini php configuration file
/etc/ips – ip addresses on the server (except the shared ip) (IP Functions–>Show IP Address Usage )
/etc/ipaddrpool – IP Addresses which are free
/etc/ips.dnsmaster – name server ips
/var/cpanel/Counters – To get the counter of each users.
/var/cpanel/bandwidth – To get bandwith usage of domains
/var/cpanel/bandwidth – rrd files of domains
/var/cpanel/username.accts : reseller accounts are listed in this files
/var/cpanel/packages : hosting packages are listed here
/var/cpanel/root.accts : root owned domains are listed here
/var/cpanel/suspended : suspended accounts are listed here
/var/cpanel/users/ : cpanel user file – theme, bwlimit, addon, parked, sub-domains all are listed in this files
/var/cpanel/zonetemplates/ : dns zone template files are taken from here
Common cPanel/WHM scripts
/scripts/addns :add a dns zone
/scripts/addfpmail :Add frontpage mail extensions to all domains without them
/scripts/addfpmail2 : Add frontpage mail extensions to all domains without them
/scripts/addnobodygrp :Adds the gorup nobody and activates security
/scripts/addpop :add a pop account
/scripts/addservlets :Add JSP support to an account (requires )
/scripts/addstatus : Internal use never called by user
/scripts/adduser : Ad a user to the system
/scripts/bandwidth : Bandwidth
/scripts/betaexim :Installs the latest version of exim
/scripts/biglogcheck :looks for logs nearing 2 gigabytes in size
/scripts/bsdcryptoinstall :Installs crypto on FreeBSD
/scripts/bsdldconfig : Configures the proper lib directories in FreeBSD
/scripts/bsdpkgpingtest :Tests the connection speed for downloading FreeBSD packages
/scripts/buildbsdexpect : Install expect on FreeBSD
/scripts/builddomainaddr : build domain address
/scripts/buildeximconf :Rebuilds exim.conf
/scripts/buildpostgrebsd-dev Installs postgresql on FreeBSD.
/scripts/chcpass change cpanel passwords
/scripts/easyapache recompile/upgrade apache and/or php
/scripts/exim4 reinstall exim and fix permissions
/scripts/fixcommonproblems fixes most common problems
/scripts/fixfrontpageperm fixes permission issues with Front Page
/scripts/fixmailman fixes common mailman issues
/scripts/fixnamed fixes common named issues
/scripts/fixndc fixes rndc errors with named
/scripts/fixquotas fixes quota problems
/scripts/fullhordereset resets horde database to a fresh one – all previous user data are lost
/scripts/initquotas initializes quotas
/scripts/installzendopt installs zend optimizer
/scripts/killacct terminate an account – make sure you take a backup of the account first
/scripts/mailperm fixes permission problems with inboxes
/scripts/park to park a domain
/scripts/pkgacct used to backup an account
/scripts/restartsrv restart script for services
/scripts/restorepkg restores an account from a backup file ( pkgacct file)
/scripts/runlogsnow update logs of all users
/scripts/runweblogs update stats for a particular user
/scripts/securetmp secures /tmp partition with options nosuexec and nosuid
/scripts/suspendacct suspends an account
/scripts/unsuspendacct unsuspends a suspended account
/scripts/upcp updates cpanel to the latest version
/scripts/updatenow updates the cpanel scripts
/scripts/updateuserdomains updates userdomain entries
Apache
/usr/local/apache/bin apache binaries are stored here – httpd, apachectl, apxs
/usr/local/apache/conf configuration files – httpd.conf
/usr/local/apache/cgi-bin
/usr/local/apache/domlogs domain log files are stored here
/usr/local/apache/htdocs
/usr/local/apache/include header files
/usr/local/apache/ libexec shared object (.so) files are stored here like mod_rewrite.so etc
/usr/local/apache/logs apache logs – access_log, error_log, suexec_log
/usr/local/apache/man apache manual pages
Exim
/etc/exim.conf exim main configuration file
/etc/localdomains list of domains allowed to relay mail
/var/log/exim_mainlog incoming/outgoing mails are logged here
/var/log/exim_rejectlog exim rejected mails are reported here
/var/log/exim_paniclog exim errors are logged here
var/spool/exim/input Mail queue
/scripts/restartsrv_exim Cpanel script to restart exim
/etc/valiases/domainname.com Email forwarders and catchall address file
/etc/vfilters/domainname.com Email filters file
/home/username/etc/domainname/ passwd POP user authentication file
/home/username/mail/inbox catchall inbox
/home/username/mail/domainname/popusername/inbox POP user inbox
/home/username/mail/domainname/popusername/spam POP user spambox
ProFTPD
Start – /etc/rc.d/init.d/proftpd
Conf – /etc/proftpd.conf
Log – /var/log/messages, /var/log/xferlog
FTP accounts file /etc/proftpd/username – all ftp accounts for the domain
are listed here
Pure-FTPD
Start – /etc/rc.d/init.d/pure-ftpd
Conf – /etc/pure-ftpd.conf
Anonymous ftp document root – /etc/pure-ftpd/ip-address
Mysql
Start -  /etc/rc.d/init.d/mysql
Conf  – /etc/my.cnf, /root/.my.cnf
Data directory – /var/lib/mysql – Where all databases are stored.
Database naming convention username_dbname (eg: linux_user)
Socket file -  /var/lib/mysql/mysql.sock, /tmp/ mysql.sock
SSH Service
Start  – /etc/rc.d/init.d/sshd
Conf -  /etc/ssh/sshd_config
Log -  /var/log/messages
PHP
Php can be recompiled using /scripts/easyapache
Named(BIND)
Start  – etc/rc.d/init.d/named
Conf -  /etc/named.conf
Db records -  /var/named/
Log – /var/log/message

Automatically send email when someone login server as ROOT

E-mail Alert on Root SSH Login 

  1.  Login to the server via SSH using root
  2.  cd /root
  3.  vi .bash_profile
  4.  At the end of the file add the following line:

echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@yourdomain.com

(or)



  1. Login to your linux using root user.
  2. go to /root directory by typing cd /root command.
  3. open .bashrc file for editing. You can do this by command vi .bashrc
  4. Scroll to the end of the file add add following line and same the file and log out to your ssh panel.
echo 'ALERT - Root Shell Access (servername) on:' `date` `who` | mail -s "Alert: Root Access"  email@domain.com
Replace servername by your name of server. Replace email@domain.com by your email on which you want to receive the email alert.Once you will login back to your server using root user. You will receive an email.
It sends you the email alert when somebody login through root because when you login to your root user via ssh by default batch file .bashrc get executed. So every time the file .bashrc get executed you will received an alert.

Openvz VPS Manual Migration

 
1. Stop the VPS on the old server
vzctl stop CTID
2. Copy the private area and the configuration file to the new server.
rsync -avz -e ssh /vz/private/CTID/ root@NEWSERVERIP:/vz/private/CTID/
rsync -avz -e ssh /etc/vz/conf/104.conf root@NEWSERVERIP:/etc/vz/conf
3. Start the VPS on the old server
vzctl start CTID
4. Update the SolusVM database, so the VPS appears on the new server. Run this command on the SolusVM Master.
/scripts/vm-migrate VPSID(old vps id) NODEID    (I think new node&vps  details)
VPSID = The number in the ID column next to the VPS in SolusVM. This is NOT the CID/XID.
NODEID = The number in the ID column next to the Node in SolusVM under Nodes > List
5. Give the VPS a new IP Address
Find the VPS in SolusVM and go to "IP Addresses". Add a new IP address from the list, then click on "Main IP" and make it the main IP Address. Then
remove all of the old IP Addresses under "IP Addresses"
6. Start the VPS on the new server
vzctl start CTID

Wednesday, February 22, 2017

Windows 2012 password reset:

 

To reset the password on your Windows 2012 server, simply complete the following steps:

1. Boot from the Micrsoft Windows Server 2012 DVD
2. From the Windows Setup menu, click “Next”.
3. Select “Repair your computer”
4. Under Choose and option, click on “Troubleshoot”.
5. Under Advanced options, click “Command Prompt”.
6. At the command prompt, run the following commands:
- d:
- cd windows\system32
- ren Utilman.exe Utilman.exe.old
- copy cmd.exe Utilman.exe
7. Close the command prompt and then click “Continue”.
8. The server should now boot and present the logon screen. Here click Windows Key + U.
9. At the prompt you can now change the password, by typing the following command:
- net user administrator Password123
This will set the password for the Administrator user to be Password123 (case sensitive)

Sunday, February 19, 2017



Proxmox to solus migration:


Please follow the below steps for Proxmox to solus migration:
Step 1 :   Login to Proxmox server

Step 2 :   Identify the server need to migrate using below command
                  "qm list" 
Step 3:   Stop the VM
                   "qm shutdown VMID"
Step 4:   Path of image of VPS is 

                   "/var/lib/vz/images/VMID"
Step 5: To list the files.
                    "ls -l"
Step 6: Create a VPS in solus with no template. Please make sure the HDD space is larger than raw file. In the config file (usually under /home/kvm/kvmID), check the following line:
<source file=’/dev/VG_NAME/kvmID_img’/>
and make a note;
Step 7: If file is in raw copy the file to solus (stop the VPS KVMID)
dd if=filename.raw | ssh root@nodeIP ‘dd of=/dev/VG_NAME/kvmID_img’
Example:
root@CORE11:/var/lib/vz/images# dd if=102.raw | ssh root@IPaddress 'dd of=/dev/vg_e52670v3/kvm312_img'
Step 8: If the files is in qcow2 please use below command to convert to raw file.
EG: qemu-img convert vm-102-disk-1_kvm.qcow2 -O raw 102.raw
dd if=141bak.raw | ssh root@IPaddress 'dd of=/dev/vg_e52670v3/kvm313_img'
dd if=vm-104-disk-1_bak.raw | ssh root@IPaddress 'dd of=/dev/vg_e52670v3/kvm314_img'

Saturday, February 11, 2017

VMware ESXI to SolusVM Migration

In this blog I have add the procedure to migrate a VMware ESXi vm to Solusvm KVM vps. Just follow the below steps.


Step 1: Find vmdk file in the Vmware server.

You can use below command
 
find / -name "*.vmdk"
Step 2: Stop the vm on Vmware panel.
Step 3: Get .vmdk file to destination server where you want to migrate that vm.

You can use the below command to get the .vmdk file to destination server. Run below command on destination server.
 scp -P XX root@vmwareip:/myserver/sourcefile.vmdk /destination/

Step 4: Convert to .vmdk to .img on destination.

qemu-img convert File-flat.vmdk -O raw File-flat.img


Step 5: Create a KVM VPS with disk space greater then or equal to the size of .vmdk file size and select no template and no iso when creating VPS.

Step 6: Once vps is booted up stop the VPS. Then run the below command to restore the img file to the lvm of the corresponding VPS.
 

dd if=File-flat.img of=/dev/YourVolumeGroupName/kvmid_img

Step 7: Once done boot the vps.

Sunday, January 29, 2017

CUSTOMPHP

For each customer, inside CageFS, file alt_php.ini is located in /etc/cl.php.d/alt-phpXX (XX - version of PHP, like 52 or 53). The file contains PHP extension settings and extension directives selected by customer. This file exists for each customer, for each PHP version.

Note, that this is 'local' to CageFS, and different users will have different files. The file is not visible in /etc/cl.php.d outside CageFS. If you would like to view that file, use:

# cagefsctl -e USERNAME 

to enter into CageFS for that user. Then type: exit; to exit from CageFS

This file has to be updated using cagefsctl --rebuild-alt-php-ini after updating alt-php RPMs

Admin can change individual settings for PHP extensions by changing that extension's ini file, like editing /opt/alt/php54/etc/php.d.all/eaccelerator.ini and then running:

cagefsctl --rebuild-alt-php-ini

to propagate the change.