Showing posts with label EC2. Show all posts
Showing posts with label EC2. Show all posts

Sunday, December 4, 2022

Convert a putty .ppk key to an Amazon .pem file on Mac

$ brew install putty

$ puttygen key.ppk -O private-openssh -o key.pem

Or,

$ openssl x509 -in certificatename.cer -outform PEM -out certificatename.pem

Migrate Linux server to AWS EC2

Visit: AWS Replication Agent installation 
https://us-west-2.console.aws.amazon.com/mgn/home?region=us-west-2#/sourceServers/addServers

wget -O ./aws-replication-installer-init.py https://aws-application-migration-service-us-west-2.s3.us-west-2.amazonaws.com/latest/linux/aws-replication-installer-init.py


sudo python3 aws-replication-installer-init.py --region us-west-2

Sunday, September 4, 2022

How to access EC2 instance if lost key Pair and root credentials

Step-1: 

Create a new instance with same OS as previous one or create it from AIM made from old instance

Step-2: 

Shutdown the old instance and detach the volume

Step-3: 

Shutdown new instance Attached the detached volume to new instance and start the instance

Step-4: 

Login new instance using ssh console

Run the following commands:

lsblk

df -h

cd mnt

mkdir oldvolume

sudo mount /dev/sda1 mnt/oldvolume

cd mnt/oldvolume/root/.ssh

sudo vi authorized_keys

Now add your public key and save 

umount /dev/sda1

sudo shutdown now

Step-5: 

Now detach the dev/sda1 volume from new instance and attach to old instance as dev/sda

Step-6:

Reboot old instance from AWS dashboard and login your old instance using ssh console 

 Note: Your old instance IP will be changed after doing this if no elastic IP

Thursday, August 25, 2022

How to add public key to authorized_keys ec2 instance Ubunutu Linux

 Step 1: Login into you AWS account and go to EC2 instances

Step 2: Select your instance and click connect

Step 2: Then click connect button at the bottom right corner

Step 3: Now a new tab will be opened with console as follows

Step 4: Copy your SSH public key then add the key to the following key file

Use this command in Mac/Windows powershell to copy your public key: pbcopy ~/.ssh/id_rsa.pub

nano ~/.ssh/authorized_keys

Step 5: Save and reboot then try to connect again with device from which public key generated.

Extract Domain from email in Excel or Google sheet

  =TEXTAFTER( A2 , "@") or, =MID(A1, FIND("@", A1) + 1, LEN(A1) - FIND("@", A1))