Shell scripting: Iterate over a list line-by-line instead of word-by-word

Let’s say a directory contains these files: My First File.txtMy Second File.txt If you wanted to take an action on each distinct file, you might try something like this: for file in `ls ~`; do echo $file; done The output will look like below, because the spaces and line breaks are both treated delineators of… Continue reading Shell scripting: Iterate over a list line-by-line instead of word-by-word

Restrict Access to WordPress with Nginx and GeoIP

The goal of this post is to harden your WordPress dashboard by preventing logins from countries where you know you will never be connecting. Since brute-force login attempts may still originate from an allowed country, it would be wise to combine this with other tools like fail2ban or one of the numerous plug-ins that add… Continue reading Restrict Access to WordPress with Nginx and GeoIP

Automatically update CentOS 7 with yum-cron

Install yum-cron: sudo yum -y install yum-cron Open /etc/yum/yum-cron.conf in your favorite editor and make sure each of the following values are set to ‘yes’. update_messages = yes download_updates = yes apply_updates = yes Other optional settings in yum-cron.conf # Change from ‘default’ to ‘security’ # if you only want security fixes. update_cmd = security… Continue reading Automatically update CentOS 7 with yum-cron

Published
Categorized as CentOS, Linux

Automatically Update WordPress, Themes, and Plugins using WP-CLI

WordPress is a hugely popular blog/CMS platform, but with widespread adoption comes risk: It is a common target for hackers, exploits, etc. Accordingly, you should make sure it gets regular updates. WordPress has a built-in update mechanism but this also requires that its PHP files be writable by the web server, introducing a new set… Continue reading Automatically Update WordPress, Themes, and Plugins using WP-CLI

Using SSH Keys for Passwordless Authentication

SSH keys can provide an additional layer of security (if you also disable password authentication on the server), or they can simplify the process of connecting to remote servers. For our purposes we’re interested in the latter – connecting to the server without entering a password. The basic idea is that you create a public/private… Continue reading Using SSH Keys for Passwordless Authentication

File ownership considerations with Nginx and php-fpm

I recently switched my CentOS 7 web server over to Nginx and php-fpm. From my experience with Apache I assumed that PHP scripts would be executed by the same user the web server is running as — ‘nginx’ in this case. But this could no longer be taken for granted since php-fpm is a separate… Continue reading File ownership considerations with Nginx and php-fpm