fail2ban - block wp-login.php brute force attacks

Lately I had a lot of brute force attacks on my WordPress blog. I used basic auth to /wp-admin part in nginx configuration to block this and as a better solution I wan’t to block source IPs at all on firewall. To do this, place this filter code in /etc/fail2ban/filter.d/wp-login.conf: # WordPress brute force wp-login.php filter: # # Block IPs trying to authenticate in WordPress blog # # Matches e.g. # 178....

2015-12-31 · 1 min · timor

Ansible on Vagrant - skipping: no hosts matched

I have some Ansible roles to configure my vps, Raspberry Pi, etc. I like to test them before I broke something on my real, not clustered machines - I use Vagrant for that. But with it I had one problem - in playbooks I define hosts as groups of severs ex. web for my vps: Example Ansible playbook - hosts: web gather_facts: True sudo: True ... But testing machine wasn’t in this group and when I run vagrant I could only see:...

2015-12-29 · 1 min · timor

Apache - Force caching dynamic PHP content with mod_headers

Normally you want dynamic content to be fresh and not catchable. But sometimes it may be useful to cache it, like when you have website behind reverse proxy. To do this try something like this: <filesmatch "\.(php|cgi|pl)$"> Header unset Pragma Header unset Expires Header set Cache-Control "max-age=3600, public" </filesmatch> Sources http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html  external link

2015-12-29 · 1 min · timor

MySQL - reset root password

It will happen from time to time, that you’re on alien machine and have to brutally update things in db without knowing credentials. Example is for root (quite secure candidate to change because it shouldn’t be used in app 😃 ) but will work for any user. shutdown db service mysql stop create text file with command like this (update user accordingly) ex. in /tmp/pwchange.txt SET PASSWORD FOR "root"@"localhost" = PASSWORD("HereYourNewPassword"); start mysqld with --init-file param mysqld_safe --init-file=/tmp/pwchange....

2015-12-28 · 1 min · timor

Rotate movies

I hate movies recorded on phone in vertical position. This just short tip how I dealt with with it last time: for m in *.mp4 do avconv -i $m -vf "transpose=1" -codec:a copy -codec:v libx264 -preset slow -crf 23 rotated-$m done Other examples: http://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg  external link http://superuser.com/questions/578321/how-to-flip-a-video-180  external link °-vertical-upside-down-with-ffmpeg

2015-12-28 · 1 min · timor

Extract password saved in Remmina

I had some passwords saved in remmina but like it always happen, I wasn’t been able to remember them when needed. Trying to restore them I found that they’re encrypted in .remmina directory. Then I used this script to decrypt them 1: Extract script import base64 from Crypto.Cipher import DES3 secret = base64.decodestring("<STRING FROM remmina.prefs>") password = base64.decodestring("<STRING FROM XXXXXXX.remmina>") print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password) http://askubuntu.com/questions/290824/how-to-extract-saved-password-from-remmina  external link  ↩︎

2015-12-25 · 1 min · timor

Apache AuthBasic but excluding IP

Allow from IP without password prompt, and also allow from any address with password prompt Order deny,allow Deny from all AuthName "htaccess password prompt" AuthUserFile /web/askapache.com/.htpasswd AuthType Basic Require valid-user Allow from 172.17.10.1 Satisfy Any Sources http://www.askapache.com/htaccess/apache-authentication-in-htaccess.html  external link

2015-12-23 · 1 min · timor

Copy GTP partiotion table between disks

When configuring RAID it’s quite important to have the same partition tables on every disk. I’v done this many times on msdos partition tables like this: sfdisk -d /dev/sda | sfdisk /dev/sdb but it’s not working any more on GPT partition tables. Hopefully it still can be done but with different toolstack 😄 Install gdisk: apt-get install -y gdisk Then use sgdisk like this: sgdisk -R /dev/sd_dest /dev/sd_src sgdisk -G /dev/sd_dest First command will copy partition from /dev/sd_src to /dev/sd_dest....

2014-07-28 · 1 min · timor

Quickly setup SQL query logging on console in Django

There is need plugin for Django, named django-debug-toolbar but it needs some time to configure. So when I need simple way to debug SQL queries I use small hack. Add to your settings.py: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', } }, 'loggers': { 'django.db.backends': { 'handlers': ['console'], 'level': 'DEBUG', }, } } To get this working DEBUG option have to be set to True:...

2014-05-28 · 1 min · timor

Changing default php.ini file for PHP-CLI on CentOS

On Debian in default installation you have different configuration files for PHP in Apache, FPM, CLI, etc. But on CentOS you have only one php.ini for all of them. In case I have, I need to have different configuration file for scripts running in CLI mode (more memory, etc). I could run it like this: php -c /etc/php-cli.ini script.php But this a little burdensome. So I do it like this:...

2014-05-08 · 1 min · timor