Skip to content

Instantly share code, notes, and snippets.

@jdmedeiros
jdmedeiros / override_dhcp.md
Last active April 16, 2024 00:27
How to override the DHCP offered default gateway on Amazon Linux 2023

Network Configuration Management on Amazon Linux 2023

This guide details how to override the default gateway assigned by DHCP.

Opening and Editing Network Configuration

  1. Open the Network Configuration File Use nano (or any text editor of your choice) to open the network configuration file:

sudo nano /usr/lib/systemd/network/80-ec2.network

@jdmedeiros
jdmedeiros / RAID6_LVM_LUKS.sh
Created March 23, 2024 00:42
Configure RAID6 with and without LVM and encrypt with LUKS
sudo apt update && sudo apt -y upgrade
sudo apt -y install lvm2 mdadm gdisk raidutils cryptsetup
lsblk
: <<'END'
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 24.9M 1 loop /snap/amazon-ssm-agent/7628
loop1 7:1 0 55.7M 1 loop /snap/core18/2812
loop2 7:2 0 87M 1 loop /snap/lxd/27037
loop3 7:3 0 63.9M 1 loop /snap/core20/2182
@jdmedeiros
jdmedeiros / crypto-mount-lvm.service
Created March 22, 2024 23:34
Open-Mount and Unmount-Close LVM LUKS RAID6 Volume
[Unit]
Description=Open-Mount and Unmount-Close LVM LUKS RAID6 Volume
After=local-fs-pre.targe
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/bin/mkdir -p /mnt/raid6LVM
ExecStartPre=-/bin/umount /mnt/raid6LVM
ExecStart=/usr/lib/systemd/systemd-cryptsetup attach lv1_crypt /dev/vg1/lv1
@jdmedeiros
jdmedeiros / crypto-mount.service
Created March 22, 2024 23:33
Open-Mount and Unmount-Close LUKS RAID6 Volume
[Unit]
Description=Open-Mount and Unmount-Close LUKS RAID6 Volume
After=local-fs-pre.targe
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/bin/mkdir -p /mnt/raid6NoLVM
ExecStartPre=-/bin/umount /mnt/raid6NoLVM
ExecStart=/usr/lib/systemd/systemd-cryptsetup attach md0_crypt /dev/md0
@jdmedeiros
jdmedeiros / superset_config.py
Created March 5, 2024 12:27
superset_config.py with https://auth0.com/ authentication
from flask_appbuilder.security.manager import AUTH_OAUTH
SECRET_KEY = 'A1B4E2F0C3D7FE98456AC0BD34EF1234'
AUTH_TYPE = AUTH_OAUTH
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = "Admin"
OAUTH_PROVIDERS = [
{
'name': 'auth0',
@jdmedeiros
jdmedeiros / resdata.txt
Last active February 26, 2024 17:58
Resdata for CCNA 200-301
1: "AC", 2: "A", 3: "C", 4: "DE", 5: "B", 6: "B", 7: "B", 8: "AB", 9: "B", 10: "BD",
11: "D", 12: "D", 13: "AB", 14: "C", 15: "D", 16: "D", 17: "D", 18: "AD", 19: "B", 20: "A",
21: "DE", 22: "D", 23: "C", 24: "C", 25: "D", 26: "C", 27: "C", 28: "A", 29: "D", 30: "D",
31: "BC", 32: "C", 33: "C", 34: "C", 35: "BE", 36: "BC", 37: "B", 38: "B", 39: "B", 40: "D",
41: "D", 42: "D", 43: "D", 44: "DE", 45: "BC", 46: "B", 47: "C", 48: "C", 49: "C", 50: "BC",
51: "B", 52: "D", 53: "B", 54: "D", 55: "B", 56: "D", 57: "A", 58: "C", 59: "D", 60: "C",
61: "D", 62: "B", 63: "C", 64: "AE", 65: "D", 66: "AB", 67: "D", 68: "A", 69: "AD", 70: "DE",
71: "A", 72: "A", 73: "A", 74: "C", 75: "B", 76: "C", 77: "C", 78: "C", 79: "BC", 80: "A",
81: "C", 82: "C", 83: "A", 84: "D", 85: "C", 86: "C", 87: "A", 88: "A", 89: "C", 90: "D",
91: "AE", 92: "D", 93: "C", 94: "C", 95: "BD", 96: "D", 97: "BEF", 98: "AD", 99: "D", 100: "D",
#!/usr/bin/python3
import argparse
import hashlib
import json
import os
import socket
import sys
import time
@jdmedeiros
jdmedeiros / Graphical_User_Interface_On_EC2
Last active February 2, 2023 08:07
Graphical User Interface (GUI) on AWS EC2 Linux-2
Installing a Graphical User Interface (GUI) on AWS EC2 Linux-2
sudo amazon-linux-extras install mate-desktop1.x
sudo amazon-linux-extras install epel
sudo amazon-linux-extras install chromium filezilla
sudo yum -y install xrdp chromium filezilla
sudo systemctl enable --now xrdp
# This will make the graphic interface available to all users
sudo bash -c 'echo PREFERRED=/usr/bin/mate-session > /etc/sysconfig/desktop'
# Make sure to export the instance ID
# export instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
import boto3
import os
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2', region_name='us-east-1')
volume_info = ec2.describe_volumes(
Filters=[
{
@jdmedeiros
jdmedeiros / postgresql_install.sh
Created November 4, 2022 22:16 — forked from coder4web/postgresql_install.sh
PostgreSQL install and setup
:'SET PASSWORD
sudo -i -u postgres
psql
\password postgres
'
# RHEL / CentOS 8
# https://www.postgresql.org/download/linux/redhat/
# https://www.postgresql.org/docs/current/runtime.html
dnf list installed |grep postgresql