Straight to the point

Page 2 of 2

Get any user’s public key from github

This is useful when you are giving SSH access to a server. Basically, we have to append the public key to ~/.ssh/authorized_keys.

Replace the with real github username.

Custom error code in nginx

In some cases, we might need to throw a custom/different error code for a specific issue. For example, we can throw a different error to the end user even if the backend node is down. We can do that in nginx as in the example below.
server {
    listen       8080;
    error_page   502 503 504 =204 /temperror;
    location /temperror {
      return 204;
Now the user will only see a 204 even if its 503 in real

Start a temporary webserver using python SimpleHTTPServer

To start a HTTP server on port 8000 (which is the default port), simple type:

python -m SimpleHTTPServer

The PWD(present working directory) by which the command is executed will be served via HTTP. If we want to use custom port, use


python -m SimpleHTTPServer <portnumber>

For eg python -m SimpleHTTPServer 8080



Remove a commit from local and remote history

  • git reset –soft commit_id
  • git stash save “message”
  • git reset –hard commit_id
  • git stash apply stash [email protected]{0}
  • git push —force

Renaming git branch

1. Rename your local branch.
If you are on the branch you want to rename:
git branch -m new-name
2. Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
3. Reset the upstream branch for the new-name local branch. Switch to the branch and then:
git push origin -u new-name

Delete a git commit that is already pushed

git log
 to check the commit list.
For example, commit 7f6d03 was before the 2 wrongful commits and we want to restore to that commit .
Force push that commit as the new master:
git push origin +7f6d03:master
The + is interpreted as forced push.
Another way
You can also use git reset to undo things. Then force push.
git reset 7f6d03 –hard
git push origin -f

OpenSSL commands to check certificate status

* Check a Certificate Signing Request (CSR)
openssl req -text -noout -verify -in CSR.csr
* Check a private key
openssl rsa -in privateKey.key -check
* Check a certificate
openssl x509 -in certificate.crt -text -noout
* Check a PKCS#12 file (.pfx or .p12)
openssl pkcs12 -info -in keyStore.p12
Newer posts »

© 2019 Devopslife

Theme by Anders NorenUp ↑