Skip to content

Instantly share code, notes, and snippets.

Francesco Pira pirafrank

Block or report user

Report or block pirafrank

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pirafrank
pirafrank / git_mirror.sh
Created Dec 17, 2018
mirror your git repos to make a backup
View git_mirror.sh
#!/bin/bash
for url in $(ssh git.example.com ls-urls)
do
echo "Cloning $url ..."
git clone --mirror "$url"
done
@pirafrank
pirafrank / ovpn_generator.conf
Last active Jan 9, 2019
Generator of .ovpn files with hardened client config and embedded cert, key and ta.key.
View ovpn_generator.conf
client
dev tun
proto udp
remote <SERVER> <PORT>
resolv-retry infinite
nobind
persist-key
persist-tun
key-direction 1 # <-- DO NOT change this! (server.conf must have: tls-auth ta.key 0)
cipher AES-256-CBC
@pirafrank
pirafrank / exif_datetime_setter.sh
Last active Sep 28, 2018
Update EXIF datetime data from filename pattern (if not set) or update file timestamps from EXIF metadata (if it is set)
View exif_datetime_setter.sh
#!/bin/bash
# Simple script to parse JPG photo filename and set exif datetime,
# creation date and file modification date accordingly.
# Filename pattern is YYYYMMDD_hhmmss.
# Timezone is taken by your PC.
# exec this script by searching for .JPG and .jpg files in given folder
# find . -type f -name "*.JPG" -o -name "*.jpg" -exec /path/to/exif_datetime_setter.sh {} \;
@pirafrank
pirafrank / curl.md
Created Sep 19, 2018 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@pirafrank
pirafrank / share.sh
Last active Sep 17, 2018
A simple script to create a folder with a random name to be served by a web server
View share.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: no arguments given"
echo "Usage: ./share.sh file1 file2 file3 etc."
exit 1
fi
# Script variables
basepath="/var/www/sharing.example.com"
@pirafrank
pirafrank / hex_to_base64_and_back.sh
Created Sep 14, 2018
convert hex string to base64 string and viceversa
View hex_to_base64_and_back.sh
# convert hex string to base64 string
| xxd -r -p | base64
# convert base64 string to hex string
| base64 -d | od -t x1 -An
# Example: the whole circle in one command
# convert base64 to binary, to sha256 checksum (string in hex format), to decoded hex data (xxd -r),
# to base64 string, to base64 decoded data (base64 -d), back to hex string
awk '{print $2}' /etc/ssh/ssh_host_ecdsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | base64 -d | od -t x1 -An
@pirafrank
pirafrank / ssh_host_key_digest_calculator.sh
Last active Sep 14, 2018
Script to calculate digest of SSH host keys with different algorithms. Output is in HEX and Base64 formats.
View ssh_host_key_digest_calculator.sh
#!/bin/bash
keylist="/etc/ssh/ssh_host_rsa_key.pub /etc/ssh/ssh_host_dsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ed25519_key.pub"
printf "\n%s\n" "$(hostname)"
for keyfile in $keylist; do
if [ -f $keyfile ]; then
printf "\n $keyfile\n"
printf " %-6s -- %-6s -- " "SHA256" "HEX"
awk '{print $2}' $keyfile | base64 -d | sha256sum -b | awk '{print $1}'
@pirafrank
pirafrank / speedtest.sh
Created Jun 15, 2018
internet speedtest from command line
View speedtest.sh
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@pirafrank
pirafrank / ip6tables_rules.sh
Last active Jun 12, 2018
disable IPv6 on iptables
View ip6tables_rules.sh
ip6tables -P INPUT DROP
ip6tables -P FORWARD DROP
ip6tables -P OUTPUT ACCEPT
@pirafrank
pirafrank / firewalld_rules.sh
Last active Oct 10, 2018
basic firewalld rules
View firewalld_rules.sh
# basic firewalld rules and commands
# check if running
# systemctl status firewalld
# firewall-cmd --state
# list ports
# firewall-cmd --list-all
# firewall-cmd --list-all --zone=public
# firewall-cmd --list-all --zone=public --permanent
You can’t perform that action at this time.