Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
jriguera /
Created February 8, 2015 14:07
Raspberry PI password recovery for arch linux
#!/bin/bash -e
# Raspberry PI password recovery for arch
# The SD should be mounted on $DEV (usually sdb2)
# Creating SHA512 password for arch
jriguera /
Created March 9, 2015 00:57
Limit ssh connections
# requires hashlimit
iptables -I INPUT -p tcp -m tcp --dport 22 -m state --state NEW \
-m hashlimit --hashlimit 1/min \
--hashlimit-burst 5 --hashlimit-mode srcip \
--hashlimit-name SSH --hashlimit-htable-expire 120000 \
iptables -I INPUT -p tcp -m tcp --dport 22 \
jriguera /
Created March 9, 2015 01:00
Create a new openvpn client
# Create client for OpenVPN using easy-rsa
# create p12 certificate
if [ "$#" -ne 1 ]; then
jriguera / removing_GPT
Last active August 29, 2015 14:19
How to remove GPT table
Warning!! Unsupported GPT (GUID Partition Table) detected. Use GNU Parted
To go back to the normal MBR:
# parted /dev/sda
# mklabel msdos
# quit
Or, do it in a single line:
# parted -s -- /dev/sda mklabel msdos
jriguera / 00-openvpn-bittorrent.txt
Last active February 4, 2018 09:39
Split routing for bittorrent in Arch
By doing these steps, transmission will be listening only on the VPN interface/network.
As debian/ubuntu are now using systemd, the following instructions should work on those distros.
1) Copy all shell scripts to /usr/local/bin/ and make them executable
2) Copy systemd service unit to /etc/systemd/system/
3) Install transmission: sudo pacman -Syu transmission-cli
4) Install openvpn: sudo pacman -Syu openvpn
5) Change transmission parameters: sudo vim /var/lib/transmission/.config/transmission-daemon/settings.json
6) Create the openvpn client configuration file: /etc/openvpn/client.conf
7) Enable the new service: sudo systemctl enable openvpn-bittorrent
jriguera /
Last active August 29, 2015 14:20
getting the public ip
ping -c 1 -I $dev && \
echo "Public ip: $(curl -s --interface $dev $(curl -s --interface $dev"
jriguera /
Created April 27, 2015 10:29
Connect to a linux box to see the remote screen using VNC through ssh tunnel
#!/usr/bin/env bash
# Script to connect to remote machine via ssh and export X11 via vnc using a ssh tunnel
# Author: Jose Riguera <> December 2009
# License: GNU General Public License v2 or later
# x11vnc must be installed on remote host
# xvnc4viewer must be installed on local host
jriguera /
Created April 27, 2015 11:17
Example of a creation of a new tenant in OpenStack using the command line
TENANT_DESC="Cloud Foundry"
export OS_USERNAME=admin
jriguera /
Created April 28, 2015 14:32
S3 test in java
import java.util.List;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.util.StringUtils;
jriguera /
Last active March 16, 2018 22:56
Example how to deploy a baremetal server using ironic standalone
# Create the initial ramdkisk
export ELEMENTS_PATH="/home/jriguera/diskimage-builder/elements"
ramdisk-image-create ubuntu deploy-ironic grub-install -o my-deploy-ramdisk
# Create the image to deploy on disk (with ConfigDrive support)
DIB_CLOUD_INIT_DATASOURCES="ConfigDrive, OpenStack" disk-image-create ubuntu baremetal dhcp-all-interfaces -o my-image
# Define the parameter for the new server