Skip to content

Instantly share code, notes, and snippets.

View alexbartsch's full-sized avatar

Alexander Bartsch alexbartsch

View GitHub Profile
@alexbartsch
alexbartsch / Add-SSH-Key
Last active August 29, 2015 14:02
Add Public SSH Key to Remote Server in a Single Command
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'
@alexbartsch
alexbartsch / Patch Shellshock
Last active August 29, 2015 14:06
Patch 'shell shock'
sudo apt-get update && sudo apt-get install --only-upgrade bash
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
@alexbartsch
alexbartsch / mutate-virtualbox-to-libvirt.sh
Last active August 29, 2015 14:07
Mutate a vagrant-box for using it with libvirt
#!/bin/sh
#
# This is a script to convert (by using `mutate` command of VirtualBox)
# a virtualbox image for using it with libvirt
#
wget http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box -O ubuntu-trusty-x64-vagrant.box
vagrant mutate ubuntu-trusty-x64-vagrant.box libvirt
vagrant box list
export VAGRANT_DEFAULT_PROVIDER=libvirt
@alexbartsch
alexbartsch / forward-port-via-iptables
Created November 11, 2014 13:38
Forward incoming traffic off specific port
/etc/rc.local
iptables -F FORWARD
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.122.10:80
@alexbartsch
alexbartsch / mysql-full-backup
Created November 17, 2014 09:38
Create MySQL dump for all databases
mysqldump -u root --all-databases | gzip -c > $(date +%Y-%m-%d)_name-all-databases.sql.gz
@alexbartsch
alexbartsch / vagrant-rsync-ssh-too-many-connections
Created November 20, 2014 12:00
Resolve "vagrant up" rsync error, because of "Too many authentication failures"
ssh-add $HOME/.vagrant.d/insecure_private_key
@alexbartsch
alexbartsch / git-composer-typo3-deny-access
Created November 24, 2014 08:37
Deny direct access to git and composer files.
# Deny direct access to several files
RewriteCond %{REQUEST_URI} ^/typo3_src [OR]
RewriteCond %{REQUEST_URI} ^/composer.json [OR]
RewriteCond %{REQUEST_URI} ^/composer.lock [OR]
RewriteCond %{REQUEST_URI} ^/.gitignore [OR]
RewriteCond %{REQUEST_URI} ^/.gitattributes [OR]
RewriteCond %{REQUEST_URI} ^/phpci.yml
RewriteRule .* / [L,R=301]
@alexbartsch
alexbartsch / aws-opworks-non-standard-git-port
Created February 25, 2015 21:13
Use AWS OpsWorks deployment with non standard git port.
ssh://git@domain.com:__YOUR-PORT__/path-to/repository.git
@alexbartsch
alexbartsch / create-vm-from-iso.sh
Last active August 29, 2015 14:27 — forked from srics/create-vm-from-iso.sh
Create KVM Virtual Machine using Ubuntu Trusty ISO image
#!/bin/bash -x
VM_NAME=_base_trusty64_openstack
VM_MEM=8192
VM_VCPUS=4
VM_DISK_ISO=/var/lib/libvirt/images/ubuntu-14.04.1-server-amd64.iso
VM_NETWORK="bridge=br-ext"
VM_PATH=/opt/vms/${VM_NAME}
VM_DISK=${VM_PATH}/${VM_NAME}_disk.qcow2
@alexbartsch
alexbartsch / virt-resize-guest-disk.sh
Last active September 24, 2016 19:36
Resize vm guest disk space
# http://libguestfs.org/virt-resize.1.html
virt-filesystems --long --parts --blkdevs -h -a /home/libvirt-images/cloud-01_default.img
# Name Type MBR Size Parent
# /dev/sda1 partition 83 40G /dev/sda
# /dev/sda device - 40G -
# truncate -s 128G cloud-01_default-resized.img
qemu-img create -f qcow2 -o preallocation=metadata cloud-01_default-resized.img 128G