Skip to content

Instantly share code, notes, and snippets.

@philroche
philroche / ubuntu_package_download_deb.py
Last active February 26, 2024 19:44
Download a deb from launchpad for a specific package version and architecture
#!/usr/bin/env python3
import faulthandler
import functools
import logging
import sys
import click
from debian import debian_support
@philroche
philroche / launch-qcow2-image-qemu-40G.sh
Created November 8, 2023 08:39
launch-qcow2-image-qemu-40G.sh
#!/bin/bash -eu
LAUNCHPAD_USER=""
LAUNCHPAD_USER_STRING=""
GIT_HUB_USER=""
GIT_HUB_USER_STRING=""
SSH_KEY=""
SSH_KEY_STRING=""
CREATE_BACKDOOR_USER="false"
PLAIN_TEXT_PASSWORD=""
@philroche
philroche / bash-to-zsh-hist.py
Created January 17, 2022 08:58 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@philroche
philroche / configure-nodes-for-ssh-access.sh
Last active October 21, 2021 12:23
Configure SSH for access across nodes - 2021 PTG directord hackfest
# Get SSH-config for nodes
vagrant ssh-config node0 > node0.ssh-config
vagrant ssh-config node1 > node1.ssh-config
# get teh SSH key path from the ssh-config
node0_ssh_key=$(ssh -F ./node0.ssh-config -G node0 | grep -m1 -oP "(?<=identityfile ).*")
echo ${node0_ssh_key}
node1_ssh_key=$(ssh -F ./node1.ssh-config -G node1 | grep -m1 -oP "(?<=identityfile ).*")
echo ${node1_ssh_key}
@philroche
philroche / healthchecks.sh
Created May 14, 2021 14:43 — forked from rcj4747/healthchecks.sh
Run a command and report status to https://healthchecks.io
#!/bin/bash -eu
set -o pipefail
# Run a command and report status to https://healthchecks.io
usage() {
echo "Usage: $0 <healthchecks.io UUID> <command>"
exit 1
}
trap usage EXIT
@philroche
philroche / oscap-manifest.txt
Created March 30, 2021 09:58 — forked from ThinGuy/oscap-manifest.txt
OpenSCAP OVAL Scanning Ubuntu Manifest Files
#!/bin/bash
##############################################################################
# ossa.sh - Open Source Security Assessment
#
#
# Author(s): Craig Bender <craig.bender@canonical.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
@philroche
philroche / aws_ec2_describeInstanceTypes.py
Created September 2, 2020 16:50 — forked from rcj4747/aws_ec2_describeInstanceTypes.py
Play with AWS EC2 describe_instance_types
"""
Play with AWS EC2 describe_instance_types
"""
from boto3.session import Session
sess = Session()
ec2c = sess.client('ec2')
resp = ec2c.describe_instance_types()
@philroche
philroche / img-convert
Created April 2, 2020 13:08 — forked from smoser/img-convert
Utility for converting a disk image in raw format or some format qcow understands into VHD format.
#!/bin/bash
VERBOSITY=0
TEMP_D=""
FORMATS=(
qcow2
qcow2-compressed
raw
azure
azure-dynamic
azure-fixed
@philroche
philroche / README.md
Created January 31, 2020 10:10 — forked from smoser/README.md
backdoor-image

backdoor-image

Description

backdoor-image can be used to easily add user with passwordless sudo access to a image or a root filesystem.

Operating on an image requires the 'mount-image-callback' tool from cloud-utils. That can be installed on ubuntu via apt-get install -qy cloud-image-utils.

@philroche
philroche / cloneawsinstance
Created November 29, 2019 16:44
cloneawsinstance function to clone an aws instance in the same region as the source instance
function cloneinstance {
awsinstanceid=$1
region=${2:-us-east-1}
awsprofile=${3:-seg}
export AWS_DEFAULT_REGION=$region
dt=$(date '+%Y%m%d%H%M%S')
ami=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].ImageId' --output=text)
privatekey=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].KeyName' --output=text)
securitygroup=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].NetworkInterfaces[].Groups[].GroupId' --output=text)
instancetype=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].InstanceType' --output=text)