Posts

Showing posts from July, 2017

Bash script while loop case statement example

Image
How to create "Menu Lists" use Bash script while loop case statement. I'm use while loop with case statement create "Menu Lists". Bash script for fun! The display color for echo command Red color RED='\033[0;31m'   Blue color BLUE='\033[0;34m' No color NC='\033[0m' Read from standard input and write to standard output and files tee -a /tmp/log__$DATE  To run bash script [huupv@huupv ~]$ ./menu_list  The display as below:  Menu Lists  1) My blog  2) Your name  3) How old are you?  4) Your Hobbies  5) Quit >> My full bash script "bash script while loop case statement" example #!/bin/bash # author: HuuPV RED='\033[0;31m' BLUE='\033[0;34m' NC='\033[0m' #No color DATE=$(date +%Y%m%d) while true do     echo ""     echo -e "$BLUE Menu Lists $NC"     echo -e ""     echo -e "$BLUE 1) My blog $NC"     echo -e "$BLUE 2)

zimbra ldap reset last login time

Image
How to change last login time for all accounts in zimbra ldap. I'm running scripts on zimbra ldap with zimbra account. To use zimbra  8.6 The explain scripts zimbra ldap reset last login time File /tmp/email the contain accounts email, you want change last login time. cat /tmp/email The output as bellow [email protected] [email protected] when you running script, then zimbraLastLogonTimestamp change the last login the current date DATE=$(date +%Y%m%d) The output as bellow 20170726 For example [email protected] with zimbraLastLogonTimestamp : 20170511135742.260Z to changed zimbraLastLogonTimestamp : 20170726000000.000Z My scripts zimbra ldap reset last login time #!/bin/bash #HuuPV rm -f /tmp/account_DN DATE=$(date +%Y%m%d) LDAP_HOST=$(/opt/zimbra/bin/zmlocalconfig ldap_host | cut -d\ '' -f3) LDAP_PASSWORD=$(/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_password | cut -d\ '' -f3) LDAP_USERDN=$(/opt/zimbra/bin/zmlocalcon

CentOS/RHEL Use yum Command To Downgrade Upgrade or Rollback Updates

Use yum Command To Downgrade Upgrade or Rollback Update. How to downgrade the package? How to upgrade the package? How to rollback update the package?. I'm running commands with root account. You may reading link below : How to reset root password on centos 7 Generate and Verify Files with MD5 Checksum in Linux use inotify-tools on centos awk useful commands examples How to  Downgrade Upgrade package use yum command The basic syntax Downgrade package yum downgrade package1 yum downgrade package1 package2 showing multiple versions of a package yum --showduplicates list package For example How to Downgrade php-fpm 7.0.21 roll-back php-fpm 5.3.3 yum downgrade php-fpm The output as bellow Resolving Dependencies --> Running transaction check ---> Package php-fpm.x86_64 0:7.0.20-1.el6.remi will be a downgrade --> Processing Dependency: php-common(x86-64) = 7.0.20-1.el6.remi for package: php-fpm-7.0.20-1.el6.remi.x86_64 ---> Package php-fpm.x86_64 0:7.0

How To Install Wordpress with nginx on CentOS 6

Image
How To Install Wordpress with nginx on CentOS 6. In this posts, the tutorial to install and configure mysql, wordpress and nginx on centos 6 step by step. I'm running account huupv as "root" privilege . Links to below you maybe likes: How to install php7 on centos 6 How to install and configure redmine on centos 6 How to owncloud 9 install ssl certificate centos 7 How To Install the BIND DNS Server on CentOS 6 KeepAlived IP Failover on CentOS & Red Hat To release version on your server cat /etc/redhat-release The output as bellow CentOS release 6.9 (Final) To update server sudo yum update To install epel-release sudo yum install epel-release To install nginx sudo yum install nginx sudo /etc/init.d/nginx start sudo yum install php-fpm php-mysql php-gd To install and configure mysql sudo yum install mysql-server sudo /etc/init.d/mysqld restart sudo /usr/bin/mysql_secure_installation To add user and database for WP_HuuPV on Mysql mysql -u root -p

How to configure ntp client server

Image
CentOS / Red Hat Configure ntp(Network time protocol) client server synchronised. NTP client ----> NTP server (192.16.1.10) To configure ntp on ntp server To configure allow port 123 on IPtables firewalls cat /etc/sysconfig/iptables The output as bellow -A INPUT -p tcp -m state --state NEW --dport 123 -j ACCEPT -A INPUT -p udp -m state --state NEW --dport 123 -j ACCEPT To configure ntp.conf file restrict 127.0.0.1 restrict 192.16.1.0 netmask 255.255.255.0 nomodify notrap restrict 172.235.0.0 netmask 255.255.0.0 nomodify notrap restrict -6 ::1 server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst server 0.asia.pool.ntp.org server 1.asia.pool.ntp.org server 2.asia.pool.ntp.org server 3.asia.pool.ntp.org To configure ntp on ntp client To configure allow port 123 on IPtables firewalls cat /etc/sysconfig/iptables The output as bellow -A OUTPUT -d 192.16.1.10/32 -m state --stat

zimbra mail server security fail2ban

Image
zimbra mail server security with fail2ban. How to configure fail2ban for prevent "brute force attack" zimbra 8.6 on centos. How to improve zimbra mail server security with fail2ban . I'm running commands as root account. Links to below you maybe likes: zimbra custom spamassassin rules How to create auto Bcc for Recipient mails for Zimbra 8.6 How to add spam filters on zimbra 8.6 How to create auto Bcc for sender mails for Zimbra 8.6 list accounts that has not logged in for the last x days in zimbra To install fail2ban yum install fail2ban nano To backup file cp /etc/fail2ban/action.d/iptables-allports.conf /etc/fail2ban/action.d/iptables-allports.conf.backup cp /etc/fail2ban/filter.d/zimbra.conf /etc/fail2ban/filter.d/zimbra.conf.backup cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.conf.backup To create zimbra.conf file cat /etc/fail2ban/filter.d/zimbra.conf The content as below # Fail2Ban configuration file # # Author: # # $Revision: 1 $ # [Def

Generate and Verify Files with MD5 Checksum in Linux

How to generate and Verify Files with MD5 Checksum in Linux. in my post, to create "checksum" folder and 3 file: file_md5,file2_md5,file3_md5 in "checksum" folder. You may reading link below : How to reset root password on centos 7 CentOS/RHEL Use yum Command To Downgrade Upgrade or Rollback Updates use inotify-tools on centos awk useful commands examples MD5 sums are 128-bit character strings(numerals and letters) resulting from running the MD5 algorithm. To create checksum folder with 3 files $ mkdir checksum $ echo "huuphan.com" > file_md5 $ echo "Phan Van Huu" > file2_md5 $ echo "huupv" > file3_md5 $ ls -ll total 12 -rw-r--r-- 1 huupv huupv 13 Jul 13 09:04 file2_md5 -rw-r--r-- 1 huupv huupv  6 Jul 13 09:04 file3_md5 -rw-r--r-- 1 huupv huupv 12 Jul 13 09:03 file_md5 To generate MD5 Checksum on a single file $ md5sum file_md5 01ff693ecd0492aca683eed0dcd2bb44  file_md5 To generate MD5 Checksum on multiple

zimbra Qualys A+

Image
How to zimbra A+ in the Qualys SSL Labs Security Test. To help system zimbra security hardening. Let's go labs. in my post,i use zimbra account ( su - zimbra)  Zimbra without Proxy ( zimbra mailbox+zimbra ldap+zimbra MTA) Tune the cipher list ( you to check zimbraSSLExcludeCipherSuites before run command) zmprov mcf +zimbraSSLExcludeCipherSuites TLS_DHE_RSA_WITH_AES_128_CBC_SHA zmprov mcf +zimbraSSLExcludeCipherSuites TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 zmprov mcf +zimbraSSLExcludeCipherSuites TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 zmprov mcf +zimbraSSLExcludeCipherSuites SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA \ +zimbraSSLExcludeCipherSuites SSL_DHE_DSS_WITH_DES_CBC_SHA \ +zimbraSSLExcludeCipherSuites SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA \ +zimbraSSLExcludeCipherSuites SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA \ +zimbraSSLExcludeCipherSuites SSL_DHE_RSA_WITH_DES_CBC_SHA \ +zimbraSSLExcludeCipherSuites SSL_RSA_EXPORT_WITH_DES40_CBC_SHA \ +zimbraSSLExcludeCipherSuites SSL_RS

zimbra reject authenticated sender login mismatch

Image
zimbra reject authenticated sender login mismatch, How To Improvement Sender Must Login/Enforcing a Match Between From Address and sasl username on Zimbra 8.6  To check zimbraMtaSmtpdRejectUnlistedSender and zimbraMtaSmtpdRejectUnlistedRecipient enable on server zimbra mta? zmprov gacf | egrep zimbraMtaSmtpdRejectUnlistedSender zmprov gacf | egrep zimbraMtaSmtpdRejectUnlistedRecipient The output as bellow zimbraMtaSmtpdRejectUnlistedSender: no zimbraMtaSmtpdRejectUnlistedRecipient: no To enabled zimbraMtaSmtpdRejectUnlistedSender and zimbraMtaSmtpdRejectUnlistedRecipient on server zimbra mta zmprov mcf zimbraMtaSmtpdRejectUnlistedRecipient yes zmprov mcf zimbraMtaSmtpdRejectUnlistedSender yes To open file /opt/zimbra/conf/zmconfigd/smtpd_sender_restrictions.cf and add reject_sender_login_mismatch after permit_mynetworks permit_mynetworks, reject_sender_login_mismatch To restart zmmtactl zmmtactl restart To test zimbra reject authenticated sender login mismatch

conditional expression bash script

Image
Conditional expression in bash script.For example, check file exists with Conditional expression Bash script checkfile.sh  [huupv@huupv scripts]$ cat checkfile.sh  The content as below: #!/bin/bash # author: HuuPV # for example basic for check file exists! FILE="/home/huupv/scripts/menu_list" if [ -f $FILE ]; then     echo -e "$FILE \t File exists!" else     echo -e "$FILE \t File not exists!" fi File operators: -a FILE        True if file exists. -b FILE        True if file is block special. -c FILE        True if file is character special. -d FILE        True if file is a directory. -e FILE        True if file exists. -f FILE        True if file exists and is a regular file. -g FILE        True if file is set-group-id. -h FILE        True if file is a symbolic link. -L FILE        True if file is a symbolic link. -k FILE        True if file has its `sticky' bit set. -p FILE        True if file is a named pipe. -r FILE