Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
@jriguera
jriguera / pass_recovery.sh
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)
USER=root
PASSWORD=hola
DEV=sdb2
# Creating SHA512 password for arch
@jriguera
jriguera / firewall-sshd-limit.sh
Created March 9, 2015 00:57
Limit ssh connections
#!/bin/sh
# 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 \
-j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 22 \
@jriguera
jriguera / openvpn-new-client.sh
Created March 9, 2015 01:00
Create a new openvpn client
#!/bin/bash
# Create client for OpenVPN using easy-rsa
# create p12 certificate
PREFIX=lu
BASE_DIR="/etc/openvpn"
DEST_DIR="$BASE_DIR/clients"
EASY_DIR="$BASE_DIR/easy-rsa"
if [ "$#" -ne 1 ]; then
@jriguera
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
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
jriguera / public_ip.sh
Last active August 29, 2015 14:20
getting the public ip
#!/bin/bash
dev=$1
ping -c 1 -I $dev ifconfig.me && \
echo "Public ip: $(curl -s --interface $dev ifconfig.me/host) $(curl -s --interface $dev ifconfig.me/ip)"
@jriguera
jriguera / remotevnc.sh
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 <[email protected]> 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
jriguera / openstack_cli_create_tenant.sh
Created April 27, 2015 11:17
Example of a creation of a new tenant in OpenStack using the command line
#!/bin/bash
TENANT=cf
PASSWORD=cf
TENANT_DESC="Cloud Foundry"
TENANT_EMAIL="[email protected]"
TENANT_NET="10.0.1.0/24"
TENANT_NET_GW="10.0.1.1"
export OS_USERNAME=admin
@jriguera
jriguera / s3.java
Created April 28, 2015 14:32
S3 test in java
import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.List;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.util.StringUtils;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.CannedAccessControlList;
@jriguera
jriguera / openstack_cli_ironic.sh
Last active March 16, 2018 22:56
Example how to deploy a baremetal server using ironic standalone
#!/bin/bash
# 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