Denny Labs

De Web Monster

How to save iptables persistently – easy way

Save current iptables settings using command iptables-save. We save it to /etc/network/iptables.v4.rules iptables-save > /etc/network/iptables.v4.rules Last we configure our box to restore it upon booting up the network interface. Configure your network interface file /etc/network/interfaces nano /etc/network/interfaces #under iface eth0 inet static .... pre-up iptables-restore < /etc/network/iptables.v4.rules tadaaa! short and... read more

Generating Certificates for MySQL Version: ‘5.5.40-0ubuntu0.14.04.1’

Generating SSL Certificates for MySQL Daemon using openssl. cd /etc/mysql # Generate a CA key and certificate with SHA1 digest openssl genrsa 2048 > ca-key.pem openssl req -sha1 -new -x509 -nodes -days 3650 -key ca-key.pem > ca-cert.pem # Create server key and certficate with SHA1 digest, sign it and convert # the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout server-key.pem > server-req.pem openssl x509 -sha1 -req -in server-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem openssl rsa -in server-key.pem -out server-key.pem # Create client key and certificate with SHA digest, sign it and convert # the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout client-key.pem > client-req.pem openssl x509 -sha1 -req -in client-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > client-cert.pem openssl rsa -in client-key.pem -out client-key.pem # Ensure mysql user got the right access chown mysql:adm *.pem # Configure MySQL to use the certificates nano my.cnf add lines ssl=1 ssl-ca=/etc/mysql/ca-cert.pem ssl-cert=/etc/mysql/server-cert.pem ssl-key=/etc/mysql/server-key.pem service mysql restart [/code] tadaaa! hope this... read more

Edit crontab of another user (linux/ubuntu)

Root access or sudo rights is required to perform this. #crontab manpage crontab [ -u user ] { -l | -r [ -i ] | -e } #Example for editing crontab for user "anotheruser" sudo crontab -u anotheruser -e #Example for listing crontab for user "anotheruser" sudo crontab -u anotheruser... read more

SugarCRM read only field in edit view

How do I make a field in SugarCRM edit view read only? SugarCRM version >= 6.5 Add below configuration lines to  <sugarcrm root>/custom/Extension/modules/<your module name>/metadata/editviewdefs.php: 'displayParams' => array ( 'field' => array ( 'disabled' => 'disabled', ), ),... read more

Redirect www to non-www nginx configuration

Redirect single domain with www to non-www. For example, redirecting of to Why do we need to redirect www to non-www or vice versa? It all because of SEO purposes. Google treats your content as duplicate when they are crawl-able from both www and non-www. Nginx configuration for single domain redirection of www to non-www . server { server_name; return 301 $scheme://$request_uri; } Nginx configuration for multiple domains redirection of www to non-www. server { server_name "~^www\.(.*)$" ; return 301 $scheme://$1$request_uri;... read more

SugarCRM compulsory/ mandatory relationship

How to configure relationship between 2 modules mandatory/ compulsory? Real life example, we have 2 custom module “Store” and “Machine Acquisition”. On new “Machine Acquisition” record creation, we need to ensure user select which “Store” the “Machine Acquisition” record belongs to. Solution: Add displayParams to the <sugar root>/custom/modules/<ModuleName>/metadata/editviewdef.php 'displayParams' => array( 'required' => true, ), Reference: SugarCRM... read more

iptables remove rules using –line-numbers

List the rules for a specific chain. Example below list the “fail2ban-ssh-ddos” chain. iptables -L fail2ban-ssh-ddos --line-numbers Example output: Chain fail2ban-ssh-ddos (2 references) num target prot opt source destination 1 REJECT all -- anywhere reject-with icmp-port-unreachable 2 RETURN all -- anywhere anywhere Delete rule line number 1: iptables -D fail2ban-ssh-ddos... read more

Error establishing a database connection on WordPress

Are you encountering database connection errors on your WordPress site? Your database status could be on “stop/waiting” Solution (using putty): First we’ll check the status of mysql sudo su - service mysql status If it shows the mysql status is “stop/waiting” we can proceed to restart it. service mysql restart Once it’s restarted, it should be up and... read more