Posts

Bash Script While Loop Menu: 5 Easy Fixes, Avoid Bugs

Image
A bash script while loop with a case statement is the classic way to build a text menu: show the options, read a choice, act, repeat. The old version of this post gave a full menu script with colours and a log through tee . It works when you type correctly at a terminal. This rewrite drives the same script with piped input in Bash 5.2.37 on Debian 13, and finds four bugs: an endless loop when the input ends, a log full of colour codes, a failure under sh , and an unquoted echo . A fixed version follows. Contents How the bash script while loop menu works Bug 1 in the bash script while loop: end of input Bug 2 and 3 of the bash script while loop: colour codes and the shell Bug 4 of the bash script while loop: unquoted variables and the case variable A fixed bash script while loop menu Common mistakes in a bash script while loop menu How to test a bash script while loop before you ship it FAQ How the bash script while loop menu works The script runs while true , prints the menu with ...

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 huupv01@mail.huuphan.com huupv02@mail.huuphan.com 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 huupv01@mail.huuphan.com 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...

Yum Command Downgrade and Rollback: 6 Easy Examples

Image
The yum command downgrade option puts a package back to an older version, and yum history can undo or roll back whole transactions. The old version of this post showed a php-fpm downgrade on CentOS 6 and a dependency error from that old yum. Today yum is only a name for dnf , and the behaviour has changed. This rewrite tests it on Rocky Linux 9.8, where /usr/bin/yum is a symlink to dnf-3 . To keep the test repeatable I built a small local repository with a package hello in three versions (1.0, 1.1, 2.0) and a library hello-libs that hello requires at exactly the same version. It is a toy package, not php-fpm, but it triggers the same dependency problems. All output comes from that run. Contents Example 1: list versions before a yum command downgrade Example 2: the yum command downgrade moves one version down Example 3: yum command downgrade to a chosen version Example 4: upgrade again with yum update Example 5: why you should not use rpm for the library Example 6: yum history...

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...

Configure NTP Client Server: 5 Easy Steps and Mistakes

Image
To configure NTP client server time sync, you need one server that answers on UDP port 123, a client that asks it, and a firewall that lets the packets through. The old version of this post was written for CentOS with the classic ntp package. This rewrite re-runs the idea on Debian 13 with ntpsec 1.2.3, in three containers on one network: a server (10.89.79.2), a client inside the allowed range (10.89.79.3) and a client outside it (10.89.79.200). One limit: a container cannot set the host clock, so I proved the server and the access rules with ntpdig queries, and I did not get a running ntpd client to report synchronisation. The real ntpd client steps are therefore described, not shown with output. Contents Step 1: install the software to configure NTP client server Step 2: configure NTP client server access with restrict Step 3: open UDP 123, not TCP, for the NTP client server link Step 4: check the NTP client server link with ntpdig Step 5: configure the NTP client to prefer ...

Zimbra Fail2ban Setup: 5 Mistakes That Leave Logins Open

Image
Fail2ban watches log files and blocks an IP address after too many failed logins. In July 2017 I added it to a Zimbra 8.6 server on CentOS to stop brute-force attacks on webmail and SMTP. This rewrite keeps my original steps and the real mailbox.log lines from that server, checks them against the Zimbra Administrator Guide, and replays them through Fail2Ban 1.1.0 on Debian 13 in a container. The test found a problem I had missed in 2017: my filter did not match a single one of those failed logins. Contents How fail2ban protects a Zimbra mail server The 2017 setup on Zimbra 8.6 Test result: the 2017 filter matched 0 of 7 lines A filter that matches the real mailbox.log Put the jail in jail.local, not jail.conf Postfix recipient rejects and e-mail alerts 5 fail2ban mistakes to avoid on Zimbra FAQ How fail2ban protects a Zimbra mail server The Zimbra Collaboration Administrator Guide lists the logs that matter. /opt/zimbra/log/audit.log "contains authentication activity of us...

Generate and Verify Files with MD5 Checksum in Linux: A Complete Guide

Introduction Learn how to generate and verify MD5 checksums in Linux with step-by-step instructions. This comprehensive guide will help you ensure file integrity using MD5 checksums, complete with practical examples. File integrity is a crucial aspect of managing data on any Linux system. Whether you're handling sensitive information, distributing software, or simply ensuring that your files haven't been tampered with, MD5 checksums offer a straightforward solution. An MD5 checksum is a 128-bit character string that acts as a unique fingerprint for a file. In this guide, we will cover how to generate and verify MD5 checksums for your files, including creating a sample directory with files for practical demonstration.   What is an MD5 Checksum? An MD5 checksum is a 32-character hexadecimal number generated by the MD5 (Message-Digest Algorithm 5) cryptographic hash function. This checksum is used to verify the integrity of files, ensuring that they have not been altered or corr...

Zimbra Qualys A+: 3 Proven Fixes for an SSL Labs A+

Image
In 2017 I hardened our Zimbra servers until the Qualys SSL Labs test gave them an A+. This post keeps those Zimbra Qualys A+ steps, then checks them against 2026: the cipher list, the HSTS header and the Diffie-Hellman file. The short version: the old cipher list is now Zimbra's own default, TLS 1.0 and 1.1 alone cap the grade at B, and the A+ comes from one header. Each Zimbra Qualys claim below was tested with a grading scanner. Lab note: Zimbra is not installed for this test. Zimbra's web proxy is nginx, so the lab runs nginx 1.26.3 with OpenSSL 3.5.7 in a debian:13 container, a private CA for the certificate, and testssl 3.2.1, whose rating follows the "SSL Server Rating Guide" that Qualys SSL Labs publishes. It is marked experimental and is not the Qualys service itself, but it applies the same caps (TLS 1.0/1.1, HSTS). The Zimbra attribute names and defaults come from Zimbra's attribute file zimbra-attrs.xml and the Zimbra commands from my 2017 servers....

Zimbra Sender Login Mismatch: 4 Easy Steps, Avoid Lockouts

Image
A sender login mismatch happens when a user logs in to your mail server as one account but sends mail with the address of another. On Zimbra you can make Postfix refuse a sender login mismatch, so a stolen or careless account cannot pretend to be your CEO. This article shows the four steps from the original post and, more importantly, what the Postfix documentation says each setting does, so you do not lock out your own users. How this article was written: there is no Zimbra server in the author's lab, so nothing here is a fresh test run. The commands and the two zmprov outputs come from the original post, where an operator ran them on a real Zimbra mail server. All explanations of Postfix behaviour are taken from the Postfix postconf(5) manual . Contents What a sender login mismatch check does How the sender login mismatch map is searched Check the Zimbra unlisted sender settings Enable the settings and add the restriction Test the sender login mismatch rule safely What the s...