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 / 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 / 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 <jriguera@gmail.com> 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="cloud-foundry@springer.com"
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 / pretty_wget_download.sh
Created June 7, 2015 12:22
Pretty download wrapper for wget
#!/usr/bin/env bash
download() {
local url="$1"
local destin="$2"
echo -n " "
if [ ! -z "${destin}" ]; then
wget --progress=dot "${url}" -O "${destin}" 2>&1 | grep --line-buffered "%" | \
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
@jriguera
jriguera / nova_scheduler_options.txt
Created June 10, 2015 08:35
Openstack nova Scheduler
# To control the way the scheduler select the host where running a vm:
# Default value is 1.0, negative means that will pack vms on one host
ram_weight_multiplier = -1.0
@jriguera
jriguera / delete_nova.sh
Last active August 29, 2015 14:23
Delete nova compute node
root@node-11:~# nova hypervisor-list
+----+--------------------------+
| ID | Hypervisor hostname |
+----+--------------------------+
| 3 | node-8 |
| 6 | node-12 |
| 9 | node-15 |
+----+--------------------------+