June 11, 2022

Configure a API Backend Server with custom domain on Amazon Web Services (AWS) EC2 Ubuntu with NGINX and Certbot SSL

Hi all,

Build your own API backend server on AWS free-tier with SSL.

The below steps with reference links will provide detailed information of each step.

  1. AWS account - Free-tier
  2. Create EC2 Ubuntu
  3. Connect to Ubuntu from your local using SSH/Putty
  4. Install NodeJS
    1. Open terminal
    2. curl -fsSL http://deb.nodesource.com/setup_lts.x | sudo -E bash -
    3. sudo apt update
    4. sudo apt install nodejs //installs latest LTS nodejs
  5. Create a sample node server
  6. Install and configure node server process manager
    1. sudo npm install -g pm2@latest
    2. Navigate to nodejs server folder
    3. pm2 start <filename>
    4. pm2 startup systemd
    5. pm2 save
    6. pm2 list // List all the nodejs apps with status
    7. pm2 stop/restart/start app_name/id // Actions of nodejs servers
  7. Install Nginx
  8. Configure your domain DNS records to map to AWS EC2 public/elastic IP address
  9. Secure Nginx with SSL certs

Hope the above information is useful to set up the environment and play with your backend server.

Feel free to send your feedback and comments to psrdotcom@gmail.com

June 09, 2022

Generate Free SSL HTTPS Certificates with 90 days validity using letsencrypt

 Hi all,

As discussed in my earlier blog, Generate Free SSL Certificate using ZeroSSL where the limitation of one free certificate on ZeroSSL can be eliminated using Get HTTPS for free!

This process includes the following prerequisites and procedures.

Note: This process is not for beginners or production usage scenarios. Use this process if you are knowledgeable about certificate generation.


  • OpenSSL command line
  • [Li]nix / Mac OS


  • Open the URL https://gethttpsforfree.com
  • It has 5 steps
    • Account Info
    • Certificate Signing Request
    • Sign API Requests
    • Verify Ownership
    • Install Certificate
  • In each step, some commands or processes need to be followed to get the free SSL certificate.

  1. Account Info
    1. In this step, we will be providing the email and public key.
    2. Keep the generated private key security in your system.
      • Note: If you are unsure about the public key generation commands, click on the "how do I generate this?" link, which is available over the public key input textbox.
  2. Certificate Signing Request (CSR)
    1. Generate the CSR for the required domains
      • Note: You can generate the CSR for wildcard certificates and www subdomain with the same command
    2. Try to follow the same format, including the line feeds mentioned below.
    3. #change "/etc/ssl/openssl.cnf" as needed:
          #  Debian: /etc/ssl/openssl.cnf
          #  RHEL and CentOS: /etc/pki/tls/openssl.cnf
          #  Mac OSX: /System/Library/OpenSSL/openssl.cnf
          openssl req -new -sha256 -key domain.key -subj "/" \
            -reqexts SAN -config <(cat /etc/ssl/openssl.cnf \
            <(printf "\n[SAN]\nsubjectAltName=DNS:foo.com,DNS:www.foo.com")) 
  3.  Sign API Requests
    1. Sign all the requests with the private key
    • Note: You need to copy the command and execute it on your PC/Mac terminal, and the result needs to be pasted on the web page.
  4. Verify Ownership
    1. In this step, you need to prove your domain ownership
    2. You will be given 3 options
      1. Python server
      2. file-based
      3. DNS record (I've used this option)
        1. Update the DNS records with new TXT entries, and use the online dig tool to make sure the records are visible.
        2. After we verify the availability of the records, you need to click on the respective buttons on the web page.
    3. Repeat the same steps for each domain on CSR (www and any sub-domains).
  5. Install Certificate
    1. You will be able to receive your certificate in "chained.pem" format
    2. Copy and paste the first certificate section (e.g. the first "-----BEGIN CERTIFICATE-----" section) into a text file named "domain.crt".
    3. Copy and paste the second certificate section (e.g. the second "-----BEGIN CERTIFICATE-----" section) into a text file named "intermediate.pem".
    • Note: Expand the "how do I install this?" link for quick help.
Hope this will help you to generate free SSL for your websites.

Request you to send your valuable feedback and comments to psrdotcom@gmail.com

April 29, 2022

Publish and Consume NPM Packages using GitHub Package Manager

 Hi folks,

We are used to publishing the npm packages on npmjs.com. Today, I will show how we can publish the npm packages to GitHub and the steps to use those packages.

1. Publishing Packages


We need to have an account with GitHub

JavaScript native/framework based project with package.json

Add the .npmrc file to your project with the following syntax. Change the OWNER value to your GitHub account or organization name.


Publishing Process to GitHub

Create personal access token using the following steps

  • Login to GitHub
  • Go to Settings
  • Navigate to "Developer Settings" -> "personal access tokens"
  • Generate token with write:packages access permissions

  • Open terminal in the project folder
  • Execute the command to login
  • npm login --scope=@OWNER --registry=https://npm.pkg.github.com
  • When prompted,
    • Username: GitHub username
    • Password: Personal access token
    • Public e-mail: Your email address
  • Enter the following command to publish the package
  • npm publish

2. Consume/Installing the packages


We need to have an account with GitHub


Add the .npmrc file to your project with the following syntax. Change the OWNER value to your GitHub author or organization name.


Enter the full name @OWNER/package-name-version in dependencies in package.json
Install the dependencies
npm install

Note: If the organization is asking for authorization of personal access token, then you need to authorize from the personal access token section against the token for the respective organization.

Hope you will make use of GitHub for publishing the packages and consuming them with ease.

Request you to send your feedback and comments to psrdotcom@gmail.com

March 14, 2022

Change default directory of Windows command prompt and Windows PowerShell

 Hi all,

Today I will explain the steps to change the default directory for Windows command prompt and Windows PowerShell.

The default directory for both the command prompt and PowerShell is the "system32" folder of the OS installed directory (By default: "C:\windows\system32").

Day in - Day out, we will open the terminals (command prompt / PowerShell) and navigate the source directory. It sometimes irritates and wastes lots of time.

I have come across this situation and want to avoid re-entry the change directory command.


I use the command prompt and PowerShell, which are pinned to the taskbar of Windows.

Change default directory of Windows Command Prompt

  1. Right-click on the taskbar pinned Command Prompt icon
  2. Right-click on the "Command Prompt" menu
  3. Select the "Properties" item
  4. Under the "Shortcut" tab, you will find the "Start in:" label
  5. In the respective text box, enter the path you want to navigate by default.
  6. For example, "C:\Projects".

Change default directory of Windows PowerShell

  1. Open the PowerShell with administrator privileges
  2. Create a profile by using the following steps
    1. New-item -type file -force $Profile
  3. This will create a file "Microsoft.PowerShell_profile.ps1" in the current user documents PowerShell folder.
    1. Syntax
        • C:\Users\<UserName>\Documents\WindowsPowerShell
      1. Example
          • C:\Users\PSR\Documents\WindowsPowerShell
      2. Edit file
          • notepad.exe $Profile
        1. Change the default directory
          1. Syntax
              • Set-Location <Directory Path>
            1. Example
                • Set-Location C:\Projects
                  • Clear-Host # To clear the PowerShell screen
              1. Save and close the file
              2. In the PowerShell window, enter the following command to change the profile
                  • . $Profile
                1. It immediately changes from the current directory to the updated default directory.
                2. Close the PowerShell and try to open the PowerShell again to see the change in the directory.
                Hope the above information is helpful to you reduce the change directories in day-to-day life.

                Send me your valuable feedback to psrdotcom@gmail.com.

                March 10, 2022

                Git remove a specific commit(s) from history

                 Hi all,

                This blog post will let you know about the process of removing the git commit from git history.

                Sample Git log

                > git log 

                38384b3 initial commit

                f96751b UI changes

                2154131 file added

                bf9b9c1 Logic corrections

                3e75ab7 Bug fix -> (HEAD)

                Use case

                Remove the commit "file added"


                • Rebase in interaction mode one commit above which we want to remove.

                > git rebase -i f96751b

                • All the commits up to the specified commit will be listed in an order with the prefix "pick". Along with commit messages, the useful commands are available like below.

                pick = use commit

                reword = use commit, but edit the commit message

                edit = use commit, but stop for amending

                squash = use commit, but meld into previous commit

                fixup = like "squash", but discard this commit's log message

                exec = run command (the rest of the line) using shell

                drop = remove commit

                • Delete the unwanted commits from the file
                  • Press 'd' twice to delete line (in case of vi editor)
                • Save and quit the editor
                  • esc -> :wq (in case of vi editor)
                • If there are any merge conflicts, resolve it and perform rebase continue
                  • > git rebase --continue
                • Once all the merges are completed, perform the push operation
                  • > git push --force-with-lease origin
                Hope this helps you make sure, you have clean git history.

                Feel free to send your suggestions and comments to psrdotcom@gmail.com

                February 02, 2022

                Ubuntu - update NPM and NodeJS

                Hi folks,

                Some people often confuses with NPM update vs Node.js update.

                Let me clarify that, NPM (Node Package Manager) is a CLI (Command Line Interface) to manage the JS (JavaScript) packages from https://www.npmjs.com/ or any other external package managers like GitHub.

                Node.js is a FrontEnd JavaScript Framework like Vue.js, AngularJS which helps to build the scalable network applications. Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

                NVM (Node Version Manager) and n are command line utilities to manage and switch between Node.js versions.

                When you are installed for the first time, you will be installing Node.js from https://nodejs.org/en/download/ which also installs NPM CLI utility.

                But when upgrading the NPM or Node.js, it's a different story.

                Update NPM

                npm install -g npm

                Update Node.js with Node version manager (n)

                Install the n

                sudo npm install -g n

                Update the Node.js to stable version

                sudo n stable

                As of now, the stable version is 16.3.2 which includes NPM 8.1.2

                Update the Node.js to current version

                sudo n current

                As of now, the current version is 17.4.0 with NPM 8.3.1

                Check the versions


                npm --version


                node --version

                Hope this helps you to understand the NPM and Node.js difference along with update of individual components.

                Send your comments and feedback to psrdotcom@gmail.com


                January 29, 2022

                Yono SBI - Scan QR and contactless ATM cash withdrawal

                 Hi folks,

                I had seen something, I want to do and I have done PoC sometime back. Which is contactless ATM cash withdrawal from SBI Yono Mobile app.


                1. Visit the SBI ATM which supports QR Scan option on KIOSK ATM screen
                2. Select the QR based Contactless Withdrawal option on the touch screen
                3. Open the Yono Mobile app which is already registered with your SBI account and have enough funds to withdraw
                4. On mobile app, select "QR Cash Withdrawal" option
                5. Scan the ATM displayed QR from the Yono mobile app
                6. Select the amount to withdraw on ATM machine
                7. Enter the PIN or OTP when prompted
                8. Money from ATM will be dispensed
                9. This is almost contactless except, you need to touch the ATM screen twice to select the QR option and to select amount.

                This way, we can have less touch points to stay safe and secure way to withdraw your money.

                Hope you will use this option to withdraw money from an SBI ATM.

                Send your valuable feedback and comments to psrdotcom@gmail.com

                Calculate the private key of RSA algorithm

                 Hi folks,

                Today we are going to see how we can calculate the private key of RSA.


                Random prime numbers p and q

                Public key (n, e)


                1. Compute n (Random modulus)

                n = p * q

                2. Compute e (Derived Number)

                e = (p - 1) * (q - 1)

                3. Form the public key

                GCD(pubkey, e) should be 1

                pubkey = 1 mod e

                4. Private key

                prikey = (1 + k * e) / pubkey

                0 < k < e - Iterate until we get a number without fraction

                Real example


                p = 7, q = 17, pubkey = 11

                1. n = 7 * 17 = 119

                2. e = (7-1) * (17-1) = 96

                3. pubkey = 11 

                    GCD (11, 96) = 1

                4. prikey computation

                k=0, (1 + 0 * 96) / 11 = 0.09

                k=1, (1 + 1 * 96) / 11 = 8.81

                k=2, (1 + 2 * 96) / 11 = 17.5

                k=3, (1 + 3 * 96) / 11 = 26.27

                k=4, (1 + 4 * 96) / 11 = 35

                prikey = 35

                Hoping that this blog will be useful in understanding the RSA private key computation.

                Send your valuable feedback and comments to psrdotcom@gmail.com

                Featured Post

                Java Introdcution

                Please send your review and feedback to psrdotcom@gmail.com