A Simple Bash Script for deploying an EC2 instance in AWS

A Simple Bash Script for deploying an EC2 instance in AWS

Below is a sample bash script that I created to deploy an EC2 instance in AWS.

What does this script do?

-Load the at the user defined values for VPC,Subnet, Security Policy.
-Use aws cli to interact with AWS with the IAM user configured.
-Create a new AWS key named “devenv-key” and store the corresponding key in your local machine.
-Deploy an t2.micro ubuntu EC2 instance.
-Upon deployment, it will wait for 60 seconds and SSH directly into the newly deployed ubuntu ec2 instance.


-An Amazon AWS account.(Free or Paid account)
-An IAM user with Access Key and secret access key.
Pre-configured VPC, Subnets, Routes, Internet gateways, Security policy.
-Any Linux Machine with aws cli utlity installed.
[Refer to my previous blog post on how to install AWS CLI tool.]
Link: https://techantidote.com/how-to-install-aws-cli-in-linux-auto-command-completion/

– In host machine, run “aws configure” to configure your IAM user details.

[ PS: I am not a expert in scripting. ]

Variables to be set before running the script:

-I have added the following variables in the script:


-Substitute values for these variables from that of your AWS environment in the script.

How do I run the script?

Option 1: Git clone and run it

-I have setup a public project in gitlab. You can clone and run the script (You would require git to clone the project.)

git clone https://gitlab.com/techantidote/aws-bash.git
cd aws-bash

-Edit the script getaws.sh and update values for vpc_id, sub_id and sec_id.
-Once done, run the script:


Option 2:
-Create a file (getaws.sh), make it executable, copy the below contents to this file and run the script.

Bash Script starts here:

echo -e "\e[33m ========= AWS Automation Project =========\033[0m"

#AWS variables - Modify these as per your account
# Enter your VPC ID

# Enter your Subnet ID.

#Enter your route table ID - Optional

#Enter internet gateway - Optional

# Enter your security group ID

# Enter the AWS Image ID you would like to deploy. The below image ID is for an Ubuntu EC2 instance.

#Set the type of instance you would like. Here, I am specifying a T2 micro instance.

# Create an optional tag.

#Create the key name what you want

#Generate a random id - This is optional

# Generate AWS Keys and store in this local box
echo "Generating key Pairs"
aws ec2 create-key-pair --key-name devenv-key --query 'KeyMaterial' --output text 2>&1 | tee $ssh_key

#Set read only access for key
echo "Setting permissions"
chmod 400 $ssh_key

echo "Creating EC2 instance in AWS"
#echo "UID $uid"

ec2_id=$(aws ec2 run-instances --image-id $aws_image_id --count 1 --instance-type $i_type --key-name $aws_key_name --security-group-ids $sec_id --subnet-id $sub_id --associate-public-ip-address --tag-specifications 'ResourceType=instance,Tags=[{Key=WatchTower,Value="$tag"},{Key=AutomatedID,Value="$uid"}]' | grep InstanceId | cut -d":" -f2 | cut -d'"' -f2)

# Log date, time, random ID
date >> logs.txt
#pwd >> logs.txt
echo $ec2_id >> logs.txt
echo ""

echo "EC2 Instance ID: $ec2_id"
#echo "Unique ID: $uid"
elastic_ip=$(aws ec2 describe-instances --instance-ids $ec2_id --query 'Reservations[0].Instances[0].PublicIpAddress' | cut -d'"' -f2)
echo -e "Elastic IP: $elastic_ip"
echo $elastic_ip >> logs.txt
echo "=====" >> logs.txt

#echo "Copy paste the following command from this machine to SSH into the AWS EC2 instance"
#echo ""
#echo -e "\e[32m ssh -i $ssh_key [email protected]$elastic_ip\033[0m"
echo ""
echo "Please wait while your instance is being powered on..We are trying to ssh into the EC2 instance"
echo "Copy/paste the below command to acess your EC2 instance via SSH from this machine. You may need this later"
echo ""
echo "\033[0;31m ssh -i $ssh_key [email protected]$elastic_ip\033[0m"

while [[ ${temp_cnt} -gt 0 ]];
printf "\rYou have %2d second(s) remaining to hit Ctrl+C to cancel that operation!" ${temp_cnt}
sleep 1
echo ""

ssh -i $ssh_key [email protected]$elastic_ip


Note | Disclaimer:

-I build this very basic script to learn about aws cli (Probably the hard way :P).

-There are way more easier ways to achieve the same result using templates.

-The intention of this script was to learn about AWS CLI and in the future implement methods to control to which VPC/Subnet/IG/Security policy that an EC2 instance needs to be attached on the fly.

-This is strictly to be run on test environments and not for production.

-Terminate your EC2 instance and its resources after testing so that you do not get charged. If you are using the AWS Free tier and within the trial period, you should be fine.

Do let me know your feedback (Good / Bad)in the comments section down below.

Happy Cloud computing 🙂

How to install AWS CLI in Linux +  Auto command completion

How to install AWS CLI in Linux + Auto command completion

This is a guide on how to install aws cli utlity in Linux along with screenshots.


– Linux.
– Python 2.6.5 or higher.

[Tested on Linux Mint with bash shell. should work on Ubuntu as well.]

Update your system and its packages:

sudo apt update && sudo apt upgrade -y

Install Pip:

sudo apt install python-pip -y
sudo pip install --upgrade pip

Install the following modules:

sudo pip install setuptools
sudo pip install wheel

Install AWS CLI:

sudo pip install awscli

To verify that the installation went well, you can run the following command.

aws --version

If the output shows the aws version, then you are all set.

Enable AWS commands Auto completion:

-To enable auto completion of sub commands, run the following to check where your “aws” and “aws_completer” are located.

which aws
which aws_completer

-Copy the output of “which aws_completer”. This would the path.

For example, if the output of “which aws_completer” was “/usr/local/bin/aws_completer”, then enter the following:

complete -C '/usr/local/bin/aws_completer' aws

Heres a screenshot reference:

setup aws awscli aws_completer setup for bash

Verify if AWS command auto completion works:

-Run the following command and press press TAB on your keyboard after typing “ec” and it should give you the possible options:

aws ec

aws awscli autocompletion installation on linux mint

Add path to your .bashrc or .bash_profile:

To make the changes persistant for aws command completion, you can add the following to your “.bashrc” or “.bash_profile.

echo "complete -C ‘/usr/local/bin/aws_completer’ aws" >> ~/.bashrc

Hope this helps! 🙂


Tmux not displaying bash prompt colors

Tmux not displaying bash prompt colors

Here is a screenshot of my terminal when I open tmux:

tmux PS1 prompt before

Note: Here, my shell displays my [email protected] but it does not display it in colors  🙁

To make tmux read your bash colors, edit your tmux configuration file:

vim ~/.tmux.conf

Add the following line to the tmux config file:

set -g default-terminal "screen-256color"

Exit and save the file. Close and re-open tmux.

Now, when you open tmux you should be able to get your regular bash prompt colors. Here is a screenshot after re-opening tmux:


tmux $PS1 bash prompt color after modying tmux.conf

Hope this helps! Cheers!


Source: Link

Detroit: Become Human – The Game of Choices

Detroit: Become Human – The Game of Choices

Detroit Become Human is a game developed by Quantic Dream which gives the player multiple choices throughout the game. According to the choices you make, the game changes its course and changes direction. Each choice that a player makes has its own set of consequences that you live with throughout the game.

It took the script writer and director about 2 years to plot this game. The developers even visited Detroit, Michigan to research the setting and cast hundreds of actors from LA, London and Paris before starting the development and animation.

There are 3 main characters that would play in this game- Connor, Kara and Markus.

The game trailers are freaking EPIC!!!. The visuals are stunning, characters are realistic to the next level and the soundtrack is very carefully planted throughout the game.

Check the game trailer out below. (Use your headphones, watch in HD – Trust me, you wont regret it). The game trailer is one of the intense trailers that I have ever come across and has a vibe of Heavy Rain and Deus EX Mankind Divided.

Game Trailer:




Detroit Become Human choices screenshot gameplay



Detroit: Become Human - Connor screenshot

Detroit: Become Human Connor screenshot 2

Detroit: Become Human screenshot


Detroit: Become Human - Marcus Screenshot


Detroit: Become Human - Main Charactors

Detroit: Become Human - SWAT screenshot


Detroit: Become Human - Marcus


Detroit: Become Human – Cast


For those who are interested in the soundtrack. Check them out below:

What are your thoughts on the game trailer? Have you played it yet? Feel free to leave a comment down below.

Happy Gaming! 


Image Credits: Game Tyrant, variety, Playstation


How to get real time currency exchange rates in your Linux terminal

How to get real time currency exchange rates in your Linux terminal

This a tutorial on how to get real time currency exchange rates directly from your Linux terminal (+ lots of screenshots).


-A computer (  *facepalm* 😛 )
-Any Linux/Windows machine with curl installed.
-Free account with openexchangerates.org

We will be using the “curl” utility to perform the API requests which usually comes pre-installed in most Linux systems.

In case, yours does not have it installed, you can install it using the following:

[You can run “apt install curl” for Ubuntu based systems, or “yum install curl” for RHEL/CentOS/Fedora based systems or “dnf install curl” for newer Fedora systems.]

Step 1: Sign up for a free account in openexchange. You can use the below link:


I would suggest to create an account with a new password that you have never used before.

[Note: The free account has restrictions but should be sufficient to get latest conversion rates with base currency set as USD. With the free account we cannot change the base currency. This means with the free account you can translate 1USD to any other currency. I will create a different tutorial describing another method to get ]

Step 2: Get your APP ID

-Once you sign up for the account, you would receive an email with a verification email which will have your “APP ID”. Below is a screenshot:

APP ID for currency conversion

You would need to get this ID when performing the API call.

-Alternatively, once you have signed up you get your API key once you login to your account. Below is a screenshot:

API ID / API key from account to be used for getting currency exchange rates

Step 3: Get exchange rates:

-Open your terminal and run the following command:

curl -X GET https://openexchangerates.org/api/latest.json?app_id=enteryourAPIKEYhere

Enter your app ID after “=”. For example, if your APP ID is 1234, them you would run the following:

curl -X GET https://openexchangerates.org/api/latest.json?app_id=1234

Below is a sample output which displays the different currencies and its conversion values.

currency exchange rates in Linux terminal using API

You would notice the output is in JSON format which has values in keypairs. (For example: the “currency name”:  “value”.)

The data that is pulled is in realtime and it also displays the “timestamp” for which the currency converstions are in linux EPOC time.

Additional Information:

To know the current EPOC time in your system, you can command “date +%s” in your terminal. This is the number of seconds since 1970-01-01 00:00:00 UTC.

For simplicity, If you are looking to convert USD to a particular currency, you can simply grep the output with the currency you need to convert to.

For example: If you convert 1 USD to INR, you can simply grep the currency name to filter out the output.

curl -s -X GET https://openexchangerates.org/api/latest.json?app_id=1234 | grep INR

Below is a screenshot of the outputs.

Output for filtered currency rates in Linux terminal. USD to INR and USD CAD currency exchange rates example outputs.


Thats it folks! Hope this helps! If you liked this tutorial, leave a comment down below and follow to get future updates ! 🙂

Spectre Vulnerability Proof of Concept

Spectre Vulnerability Proof of Concept

You must have heard the tech industry has been blowing up about Spectre and Meltdown for the past week. Here is a POC for Spectre that you can run in your Server/PC to check if you are vulnerable.

-Open up your Linux terminal and run the following:

mkdir exploit
cd exploit
git clone https://github.com/crozone/SpectrePoC.git
cd SpectrePoC

[Note: You would need packages gcc, make, build-essential to test the exploit. You could use “sudo apt-get install gcc make git build-essential -y” to install the packages.]

spectre exploit git POC git

[Optional: Review the spectre.c file and optionally modify the character string.

Spectre POC code - change string

[Optional: You can change the string between the double quotes. I have changed to the one below for this test]
Spectre POC modified string example

-Finally, compile and run the exploit:

gcc -o spectre spectre.c

If you see the output which contains the characters that was stored in the *secret variable, then you are vulnerable to this exploit.Below is a sample output which indicates that the system is vulnerable to the Spectre vulnerability.

Code + Output Screenshot[Please click on the below image and open in a new tab/enarlge for better viewing]: Here, you can see the data (top to bottom in the red box) was read from a address space which the program was actually not allowed to read from.

Spectre POC exploit result and output


Spectre exploit POC output

Details of test system:

Kernel Version: 4.10.0-38-generic
Distro: Linux Mint 18.3 Sylvia – 64 bit
CPU Details:
Model: i7-4610M
cache size: 4096 KB
fpu: yes
fpu_execution: yes
clflush_size: 64
cache_alignment: 64
address sizes: 39 bits physical, 48 bits virtual

All credits go to the researchers who discovered and reported this issue => Jan Horn and Paul Kocher (along with Daniel Genkin, Daniel Gruss, Werner Haas, Mike Hamburg,Moritz Lipp, Stefan Mangard, Thomas Prescher, Michael Schwarz and Yuval Yarom).

A white paper on the exploit can be downloaded by clicking here.

If you liked this article, click on the ‘Like” button and Subscribe to my blog to get future updates. Cheers!

Sources, Credits & References:

Erik August
crozone github
Google Project Zero

Kali Linux slow update fix + Screenshots

Kali Linux slow update fix + Screenshots

After installing Kali Linux and running apt-get update if you notice slow downloads, then you could try the following to fix the issue:

Open Terminal and type the following:

vi /etc/apt/sources.list

Your sources file may look like the one below (Notice the highlighted box that indicates http):

kali linux default apt-get sources file screenshot

Now, change the text (indicated in the box) from http to repo. So, after making the changes to your mirror list(sources file), it should look like the one below:

After changing kali linux mirror screenshot

Save and close the file.

Now, run the following to verify the download speeds from the new mirrors:

apt-get clean all
apt-get update

You should notice considerable difference in running updates. Do let me know in the comments section below if this worked.



Source: Kali Forums – inkbird

DIY Honor 4C earpiece and Screen replacement

DIY Honor 4C earpiece and Screen replacement

Finally, fixed my phone’s screen and broken earpiece. This is a continuation of my previous post (Disassembling my Honor 4C ) where I dismantled my old bae – Honor 4c and this is my first DIY phone repair.

Here is the repair log:

So, I bought the display and the touch screen digitizer from ebay and it got shipped in a week.

Honor 4c screen replacement from ebay

While trying to replace the screen, I accidentally damaged the earpiece (located on the top of the phone) as I pulled it out the wrong way.

Honor 4c earpiece (broken) picture


The red rectangle shown below is the location of the earpiece(next to the secondary camera):

Honor 4c earpiece location

Well, that didn’t go as planned 🙁

Then, I did weeks of research trying to source the earpiece for the Honor 4c online but the earpiece was not available anywhere. Finally, I found it on aliexpress for $4.53 (Link) which was a good deal (including shipping from China).

I got the earpiece delivered in 1 month. It was actually pretty fast shipping considering it was shipped from another country and cleared customs in my country which usually takes a long time. Infact, this is my first item that I purchased from China and from aliexpress.

Parcel from China

Dismantled the phone (again), fixed the earpiece, and mounted the display. And here comes the moment of truth!!!

Honor 4c is Booottttiinnnnnngg!! :D

Booot was successful. 

Tested primary and secondary camera, wifi and earpiece and it was all back to normal. 🙂


Well, this project had its ups and downs, took long to complete but am am happy that I completed it.



How to check if a partition is primary in CentOS+Screenshots

How to check if a partition is primary in CentOS+Screenshots

This is a guide on how to check if a partition is primary in centos or not? Use the following command:

# parted /dev/sda print

parted /dev/sda print centos


# cfdisk /dev/sda

centos cfdisk sample output

As shown above, the field under “Part Type” would suggest if that partition is Primary/Secondary.

To exit out of the cfdisk menu, use your arrow keys and move the selection to “Quit” and hit Enter in your keyboard.

Source: Link

As always stay Happy! Happy Blogging! 🙂


Disassembling my Honor 4C

Disassembling my Honor 4C

I dropped my phone while running to work and the screen broke due to the impact. I have been using this phone for a very long time (since 13th June 2015) and I dint want to let go (probably due to sentimental value). Most people would just throw the old one away and get a new one but honestly I didn’t really feel the need to get a new one. As of now, I will wait and see. Maybe eventually I might get a new one (Honor 8 Pro maybe?) but I don’t know. So I thought I would keep it with me, give it time, learn and fix it myself even thought I have no clue what I am doing. LOL! May be this whole repair thing is a bad idea and might fail, but its definitely worth a shot.

Here is the picture of the broken screen 🙁

My Honor 4C - broken LCD screen

This is the first time ever that I am taking apart a phone completely so pardon me for any mistakes. I had completed dissembling this phone a while back but just didnt get the time to post about it due to work.

So, I googled for weeks on tutorials on stuff like how to open up this phone, the tools you need and stuff like that.

So, I bought a mobile repair kit which basically has a few screwdrivers, 2 x guitar strum looking things, 2 plastic crowbars and a suction cup. Here is a picture of the kit:

mobile repair kit

So, first thing I did was to remove the back shell.

Honor 4c back shell

So, this is how the back portion looks after removing the back shell.

So, I started off by removing the screws near the battery and then the outer ones. Attaching a picture for their location for reference:

It took me a while to figure out that there under the “Torn invalid” sticker, there is a star screw hidden underneath it. Attaching a picture for reference below:

Now, we can gently take out the blue casing. This is what looks like once we remove the blue casing on the Honor 4c.

My baby is so pretttyyy on the inside!! 🙂 😛

To remove the battery, I had to remove the two screws on the right side of the battery as shown in the red box below:

remove the two battery screws

Now to pop the battery out, I had to lift and disconnect the battery connector as show below.

After disconnecting the battery cable, I was able to remove the battery by simply lifting the battery up.

So, this is how the battery looks like:

back side of the battery

After the removing the battery, disconnect/pull  the below cable.

Honor 4c left side cable

Then disconnect the below two cables.

honor 4c two cables


Now, we can separate the motherboard from the phone.

removing honor 4c motherboard removing honor 4c motherboard 2

This is what my Honor 4c motherboard looks like.


Honor 4c motherboard

This is what the backside of the display looks like:(which has the Frame which holds the Display and the Touch Screen Digitizer).

Honor 4C LCD Display and Frame

So, I was able to disassemble my phone successfully! Wohoo!! 🙂 I know this is not a big deal for most people but its a big deal to me. I honestly didn’t think I could make it this far as I was alone in this learning journey. I am glad that I gained some knowledge on dissembling phones which is something I had never done before. I did make a video with audio instructions on the whole disassembly process but I am not sure I should upload it to my youtube channel or not. Lemme know what you think below in the comments section.

Do you think its worth repairing this and having it fixed? If you were in my shoes, would you hold on to your old phone?

Leave your comments in the comment section down below. I would love to hear what you have to say.

As always stay happy!  🙂

Happy blogging!