Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.



My Cloud Certifications:

Certified Kubernetes Administrator (CKA)

Cloud Certified Security Professional (ISC2)

CyberSecurity Certified Professional (ISC2)

AWS Certified Solutions Architect Associate

Azure Certified Architect Expert

Azure Certified Architect

Azure Certified Administrator

Oracle Cloud Infrastructure 2018 Certified Architect Associate.

Oracle Cloud Infrastructure Classic 2018 Certified Architect Associate.

Oracle Database Cloud Administrator Certified Professional.

Oracle Database Cloud Service Operations Certified Associate.

Search This Blog

Thursday, April 22, 2021

How to Install terraform on Ubuntu:

 How to install terraform on Ubuntu:


samshaik@shaikprod:~$ sudo apt-get install terraform
[sudo] password for samshaik:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package terraform


Add the terraform provider's key:
samshaik@shaikprod:~$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
OK

Add the terraform provider's repo on your debian/Ubuntu repos:

samshaik@shaikprod:~$ sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
Get:1 https://apt.releases.hashicorp.com bionic InRelease [4421 B]
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:3 https://packages.microsoft.com/repos/azure-cli bionic InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:6 https://apt.releases.hashicorp.com bionic/main amd64 Packages [22.2 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1696 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2039 kB]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1124 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1733 kB]
Fetched 6871 kB in 13s (523 kB/s)
Reading package lists... Done

Now install the package:

samshaik@shaikprod:~$ sudo apt-get install terraform
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  terraform
0 upgraded, 1 newly installed, 0 to remove and 183 not upgraded.
Need to get 32.6 MB of archives.
After this operation, 79.6 MB of additional disk space will be used.
Get:1 https://apt.releases.hashicorp.com bionic/main amd64 terraform amd64 0.15.0 [32.6 MB]
Fetched 32.6 MB in 2s (15.0 MB/s)
Selecting previously unselected package terraform.
(Reading database ... 78062 files and directories currently installed.)
Preparing to unpack .../terraform_0.15.0_amd64.deb ...
Unpacking terraform (0.15.0) ...

Setting up terraform (0.15.0) ...


Verify the version:

samshaik@shaikprod:~$ terraform -v
Terraform v0.15.0
on linux_amd64

Tuesday, April 20, 2021

Install Azure cli

 How to install azure cli on Ubuntu:


I am using wsl (Windows Subsystem for Linux) i.e I have a working Ubuntu v20 on my windows desktop & laptop and can you use my windows machine as a regular linux vm. 

More on WSL  https://docs.microsoft.com/en-us/windows/wsl/install-win10


My Ubuntu:

samshaik@shaikprod:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

If you have already azure cli installed then you can remove it as below:

sudo apt remove azure-cli -y && sudo apt autoremove -y

samshaik@shaikprod:~$ sudo apt remove azure-cli -y && sudo apt autoremove -y
[sudo] password for samshaik:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libdumbnet1
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  azure-cli
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 496 MB disk space will be freed.
(Reading database ... 67032 files and directories currently installed.)
Removing azure-cli (2.1.0-1~bionic) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  libdumbnet1
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 91.1 kB disk space will be freed.
(Reading database ... 30029 files and directories currently installed.)
Removing libdumbnet1:amd64 (1.12-7build1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...


You can install azure cli in a single command as below:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash


samshaik@shaikprod:~$ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]


Selecting previously unselected package azure-cli.
(Reading database ... 30020 files and directories currently installed.)
Preparing to unpack .../azure-cli_2.22.1-1~bionic_all.deb ...
Unpacking azure-cli (2.22.1-1~bionic) ...
Setting up azure-cli (2.22.1-1~bionic) ...


Verify the version:

samshaik@shaikprod:~$ az -v
azure-cli                         2.22.1

core                              2.22.1
telemetry                          1.0.6

Python location '/opt/az/bin/python3'
Extensions directory '/home/samshaik/.azure/cliextensions'

Python (Linux) 3.6.10 (default, Apr 19 2021, 07:29:42)
[GCC 7.5.0]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.






Thursday, June 11, 2020

How to update ssh key on a cloud VM

It happens that someone created a VM with a key and either that person isn't there anymore or forgot to share the key with others or somehow lost the key altogether. Whatever the case might be in the below blog post you will see how to update the ssh key in order to login into the VM.

For AWS:

Generate new key pair with your favorite tools.
Ex:- using openssh

samshaik@shaikprod:~$ ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/samshaik/.ssh/id_rsa): cloud-key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in cloud-key.
Your public key has been saved in cloud-key.pub.
The key fingerprint is:
SHA256:GJk8yaVsFSNxquyVLwmR6uGMxzslniA0TMQ1Ib9AO8g samshaik@shaikprod
The key's randomart image is:
+---[RSA 2048]----+
|o+.+. o.*.       |
|+o+ .= @ .       |
|+E .o &          |
| +oo.+ =         |
|. +.+ + S        |
|o*.o.o o         |
|oo*+. o .        |
| .+.   .         |
|  ..             |
+----[SHA256]-----+


Now this will create two keys (public/private) in the specified path.

samshaik@shaikprod:~$ ls -lrt ~/.ssh/cloud-key*
-rw------- 1 samshaik samshaik 1766 Jun  9 14:44 /home/samshaik/.ssh/cloud-key
-rw-r--r-- 1 samshaik samshaik  400 Jun  9 14:44 /home/samshaik/.ssh/cloud-key.pub


1) Now stop the VM
2) Include the below code snippet in the user data dialog box as follows:
Select instance --> Actions --> Instance Settings then choose View/Change User Data

Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"

#cloud-config
cloud_final_modules:
- [users-groups, once]
users:
  - name: username  (name of the user you want to change the key for ex:-ec2-user)
    ssh-authorized-keys: 
    - PublicKeypair (No quotes required and make sure you have dash at the begining)

For AWS:



3) Start the instance
Now try ssh into the instance using the updated key.


Azure:

In Azure select the VM from the left menu --> Support + Troubleshooting --> Reset Password

Here you can either create a new user/update existing user password or ssh keys










































In Oracle Cloud:









Thursday, July 25, 2019

Azure move pagefile and change drive letter for D drive



In Azure on windows VMs, D:\ drive is reserved for pagefile and any data you store on this drive will be deleted. But there are few apps or you have jobs on your on-prem that have been hard coded to use the D drive as data disk. Rather changing the drive path in your jobs it is easy to change the pagefile drive to a different drive.



So How do we move the pagefile to a different drive and rename the D drive to a drive.





Temporarily move pagefile.sys to C drive

  1. Connect to the virtual machine.
  2. Right-click the Start menu and select System.
  3. In the left-hand menu, select Advanced system settings.
  4. In the Performance section, select Settings.
  5. Select the Advanced tab.
  6. In the Virtual memory section, select Change.
  7. Select the C drive and then click System managed size and then click Set.
  8. Select the D drive and then click No paging file and then click Set.
  9. Click Apply. You will get a warning that the computer needs to be restarted for the changes to take affect.
  10. Restart the virtual machine.

Change the drive letters

  1. Once the VM restarts, log back on to the VM.
  2. Click the Start menu and type diskmgmt.msc and hit Enter. Disk Management will start.
  3. Right-click on D, the Temporary Storage drive, and select Change Drive Letter and Paths.
  4. Under Drive letter, select a new drive such as T and then click OK.
  5. Right-click on the data disk, and select Change Drive Letter and Paths.
  6. Under Drive letter, select drive D and then click OK.


Move pagefile.sys back to the temporary storage drive

  1. Right-click the Start menu and select System
  2. In the left-hand menu, select Advanced system settings.
  3. In the Performance section, select Settings.
  4. Select the Advanced tab.
  5. In the Virtual memory section, select Change.
  6. Select the OS drive C and click No paging file and then click Set.
  7. Select the temporary storage drive T and then click System managed size and then click Set.
  8. Click Apply. You will get a warning that the computer needs to be restarted for the changes to take affect.
  9. Restart the virtual machine.


Sunday, June 2, 2019

AWS Take block volume snapshots at regular intervals


Now using Data Lifecycle manager you can take block volume snapshots at regular intervals without the need of custom scripts and lambda functions.




















Under block volumes -> Life Cycle Manager --> Create Policy





Give a policy Name
You can choose either instance level snapshots (which includes all the EBS volumes attached to the instance) or individual block level volumes.

Pick a schedule:
You can  pick a window anywhere between 2hrs and 12hrs 

Retention:
How many snapshots you want to retain, AFAIK limit is 1000 snapshots and it will overwrite the oldest snapshot.

















Tags:
Pick any tags that you want to have for the snapshots.






































IAM Role:

Pick a role or create a new role with the below policy:

{
  "Version": "2018-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:CreateSnapshot",
        "ec2:DeleteSnapshot",
        "ec2:DescribeVolumes",
        "ec2:DescribeSnapshots"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "ec2:CreateTags"
      ],
      "Resource": "arn:aws:ec2:*::snapshot/*"
    }
  ]
}


Enable the policy