Saturday, July 13, 2019

PDF Compression Error

FPDF error: This document (testcopy.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI

Solution : 
Download the file from here according to your operating system.
Mine is Linux x86 (64 bit) so I have downloaded Ghostscript 9.27 for Linux x86 (64 bit)
I renamed the file as gslin64. Original filename was gs-927-linux-x86_64.
Save it in /usr/bin.
Now run the following command
gslin64 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/tmp/abc.pdf  input.pdf
where input.pdf is error pdf file and abc.pdf is error free output file which is saved inside /tmp directory 

sign_and_send_pubkey: signing failed: agent refused operation

If you are getting this ssh error while connection to any remote instance, you might have changed public and private keys recently.

To fix this issue you need to attach your ssh keys with running ssh agent. Run command
ssh-add

If you get warning 'Permissions are too open.' You need to give 400 permission to your ssh keys.

chmod 400 ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa.pub

Now it should not show error ' signing failed: agent refused operation' while connecting to remote host.

Sunday, June 9, 2019

Apache - Make specific GET request forbidden by matching pattern

If there are certain get requests which you want to make forbidden (403) on your server by matching pattern, you need to write certain rules in .htaccess or apache configuration file.

Here you can add following snippets in your apache configuration file and it will block all the GET requests which will match the pattern.

Suppose an http request is
http://porcupine.com/paymentcontroller.php?id=oculus&name=johnathan
You can block this request either by id or by name or by both. I am blocking by id.
<If "%{QUERY_STRING} =~ /id=oculus/">
  Require all denied
</If>

Reload apache.
Now all the requests contain text 'id=oculus' will be forbidden.