Skip to content

Instantly share code, notes, and snippets.

@philroche
philroche / bash-to-zsh-hist.py
Created Jan 17, 2022 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
View bash-to-zsh-hist.py
#!/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 / README.md
Created Jan 31, 2020 — forked from smoser/README.md
backdoor-image
View README.md

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 / configure-nodes-for-ssh-access.sh
Last active Oct 21, 2021
Configure SSH for access across nodes - 2021 PTG directord hackfest
View configure-nodes-for-ssh-access.sh
# 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 — forked from rcj4747/healthchecks.sh
Run a command and report status to https://healthchecks.io
View healthchecks.sh
#!/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 Mar 30, 2021 — forked from ThinGuy/oscap-manifest.txt
OpenSCAP OVAL Scanning Ubuntu Manifest Files
View oscap-manifest.txt
#!/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 Sep 2, 2020 — forked from rcj4747/aws_ec2_describeInstanceTypes.py
Play with AWS EC2 describe_instance_types
View aws_ec2_describeInstanceTypes.py
"""
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 Apr 2, 2020 — forked from smoser/img-convert
Utility for converting a disk image in raw format or some format qcow understands into VHD format.
View img-convert
#!/bin/bash
VERBOSITY=0
TEMP_D=""
FORMATS=(
qcow2
qcow2-compressed
raw
azure
azure-dynamic
azure-fixed
@philroche
philroche / cloneawsinstance
Created Nov 29, 2019
cloneawsinstance function to clone an aws instance in the same region as the source instance
View cloneawsinstance
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)
@philroche
philroche / transmission-openvpn.syno.json
Created Nov 7, 2019
Docker config for Synology NAS for docker-transmission-openvpn docker image by haugene (https://github.com/haugene/docker-transmission-openvpn). This config is for Private Internet Access. Also see https://haugene.github.io/docker-transmission-openvpn/synology-nas/ for full guide.
View transmission-openvpn.syno.json
{
"cap_add" : null,
"cap_drop" : null,
"cmd" : "dumb-init /etc/openvpn/start.sh",
"cpu_priority" : 50,
"devices" : null,
"enable_publish_all_ports" : false,
"enable_restart_policy" : false,
"enabled" : false,
"env_variables" : [
View launch_ubuntu_on_aws.sh
#!/bin/bash -e
## Launch the latest daily Ubuntu in AWS, optionally with user-data
## provided in a file and tagged with a name
function usage() {
echo "$0: [-r region] [-V ubuntu_version] [-i instance_type] \\"
echo " [-u user_data_file] [-n instance_name] [-d disk_size] \\"
echo " [-D] to disable termination via the API"
echo " [-I] iam instance profile [-a AMI ID]"
echo " [-P profile] aws cli profile"