Skip to content

Instantly share code, notes, and snippets.

View arbabnazar's full-sized avatar
🏠
Working from home

Arbab Nazar arbabnazar

🏠
Working from home
View GitHub Profile

Convert the public key into specify key format (PKCS8)

ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PKCS8 > ~/.ssh/id_rsa.pem

Using the public PKCS8 file to encrypt a string

echo "sometext" | openssl rsautl -encrypt -pubin -inkey ~/.ssh/id_rsa.pem > ~/encrypted-file.txt

OR file

@arbabnazar
arbabnazar / replace_ecs_cluster_instances.py
Created December 3, 2020 09:06 — forked from kevinmehall/replace_ecs_cluster_instances.py
Script to drain and replace EC2 instances in an ECS cluster auto-scaling group after changing the AMI or instance type
#!/usr/bin/env python3
#
# Script to replace EC2 instances in an ECS cluster's auto-scaling group after
# changing the AMI or instance type in the launch configuration. It
# checks for instances with the incorrect AMI or type, scales up the
# auto-scaling group with replacement instances, then drains the tasks
# from the old instances.
#
# Usage: aws-vault exec profile-name -- python3 replace_ecs_cluster_instances.py --group=asg-name --cluster=ecs-cluster-name --count=3
#
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeSessions",
"ssm:GetConnectionStatus",
"ssm:DescribeInstanceProperties",
"ec2:DescribeInstances",

How to use this script:

route53-zone-migrate.sh -s aws_source_profile -t aws_target_profile -d domain_name

Help

 -s,    Uses a AWS CLI profile name for Route53 zone source account.
 -t, Uses a AWS CLI profile name for Route53 zone target account.
$ git checkout --orphan NEWBRANCH
$ git rm -rf .

--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.

You can then start adding files and commit them and they will live in their own branch. If you take a look at the log, you will see that it is isolated from the original log.

@arbabnazar
arbabnazar / Java 8 PPA
Last active February 1, 2021 11:25
Java 8 working till today
sudo add-apt-repository ppa:ts.sch.gr/ppa
sudo apt-get update
sudo apt-get install oracle-java8-installer
@arbabnazar
arbabnazar / Build an AWS Lambda deployment package for Python.md
Last active January 4, 2020 19:11
Build an AWS Lambda deployment package for Python

Install all dependency modules local to the function project

pip install boto3 -t ./

Add permissions (Linux and macOS only)

chmod -R 755 .

Manually build a deployment package

@arbabnazar
arbabnazar / Change Hostname in Ubuntu 16.04 Without Restart
Created December 31, 2019 20:05
Change Hostname in Ubuntu 16.04 Without Restart
vi /etc/hosts
vi /etc/hostname
hostnamectl set-hostname stage-vpn-server
hostname
--------
OPTIONAL
--------
service hostname start
systemctl restart systemd-logind.service
let’s list block devices attached to our box:
lsblk
# install "cloud-guest-utils" if it is not installed already
apt install cloud-guest-utils
# resize partition
growpart /dev/xvda 1 OR growpart /dev/nvme0n1 1
# resize filesystem
@arbabnazar
arbabnazar / ubuntu-hardening.md
Created October 10, 2019 12:39 — forked from lokhman/ubuntu-hardening.md
List of things for hardening Ubuntu

System Updates

http://bookofzeus.com/harden-ubuntu/initial-setup/system-updates/

Keeping the system updated is vital before starting anything on your system. This will prevent people to use known vulnerabilities to enter in your system.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get autoclean