Reverting/resetting a GIT commit

If something gets committed to a GIT repo, the following command can be run to reverse it;

$ git reset HEAD~


$ git commit -m "Something terribly misguided" # (1)
$ git reset HEAD~ # (2)
<< edit files as necessary >> # (3)
$ git add ... # (4)
$ git commit -c ORIG_HEAD # (5)

If the commit has already been pushed to your external repo, you’ll need to add ‘–force’ next time you push if the commit is rejected (the repo is probably going to be ‘ahead’ of the commit you’re trying to push to it);

$ git push origin master --force


HSTS – HTTP Strict Transport Security

Enable headers module in Apace2;

a2enmod headers

In :80 host-entry;


In :443 host-entry;

Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains;"

This means browsers *should* remember that for the next year (31536000 seconds) you’ll have your site accessible via HTTPS




To prevent clickjacking, add in the following header as well;

Header always append X-Frame-Options "DENY"
Header always append Content-Security-Policy "frame-ancestors 'none';"

The 2nd line is to cater for older browsers whom don’t support the X-Frame-Options header



The resulting :443 conf file will contain;

Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains;"
Header always append X-Frame-Options "DENY"
Header always append Content-Security-Policy "frame-ancestors 'none';"

Renaming files

To renamed from ‘*.abcd.def’ to ‘*.abc’;

find ./ -depth -name "*.abcd.def" -exec sh -c 'mv "$1" "${1%.abcd.def}.abc"' _ {} \;

When using GIT;

find ./ -depth -name "*.abcd.def" -exec sh -c 'git mv "$1" "${1%.abcd.def}.abc"' _ {} \;


SSL Keys for JWT

Generate 4096 bit keys;

ssh-keygen -t rsa -b 4096

Convert to PEM format;

openssl rsa -in ms-test -pubout -outform pem >

Updating SSL certs for Jetty servers

So i’m using a standard SSL cert like any other server would have (with a cert for the domain, and intermediate cert)

The following combines the intermediate & server cert into one. Goes in order of your server cert first, followed by intermediate, next intermediate (if needed), etc.

sudo cat my-domain.crt intermediate.crt > cert-chain.txt

These then convert the chain cert & key into a pkcs12 format

openssl pkcs12 -export -inkey my-domain.key -in cert-chain.txt -out my-domain.pkcs12

This then uses the pkcs12 file and imports it into your keystore. I used a new keystore as i’ve only got the one domain on the Jetty server

sudo keytool -importkeystore -srckeystore my-domain.pkcs12 -srcstoretype PKCS12 -destkeystore keystore

These came from a number of Stack Overflow articles (accidentally closed them prior to writing this — sorry guys!)