Skip to content

Instantly share code, notes, and snippets.

Marcelo Veiga Neves mvneves

View GitHub Profile
@mvneves
mvneves / EC2LimitRegionInstanceType.json
Created Jul 16, 2018
AWS policy to limit EC2 usage to a specific region and instance type
View EC2LimitRegionInstanceType.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "limitedRegion",
"Action": "ec2:*",
"Resource": "*",
"Effect": "Allow",
"Condition": {
"StringEquals": {
@mvneves
mvneves / git-split.md
Created Dec 28, 2017
How to split a git repository into two different ones
View git-split.md

How to split a git repository into two different ones

These are the steps to extract a directory from a git repository (with all its history commit), create a new repository from this directory, and optionally remove it from the original one.

To the ones that are here to copy-paste code, this is an example which removes the MODULE directory from REPO repository.

Step 1: Extract the directory from the git repository

Clone the original repository:

@mvneves
mvneves / ssh-agent.md
Last active Aug 29, 2015
"Could not open a connection to your authentication agent"
View ssh-agent.md

SSH authentication agent does not automatically start when using it from a remote server. This result in the following error message:

$ git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
$ ssh-add ~/my-ssh-key.pem
Could not open a connection to your authentication agent.

To fix it requires manually starting ssh-agent:

@mvneves
mvneves / ssh-without-password.md
Last active Aug 29, 2015
SSH without password
View ssh-without-password.md

Using SSH without password

Generate a pair of keys in the local machine:

ssh-keygen -t rsa

Add public key to server's .ssh/authorized_keys file:

cat ~/.ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys'
@mvneves
mvneves / ec2-rsync.md
Last active Aug 29, 2015
Download an entire Amazon EC2 instance to local host using rsync
View ec2-rsync.md

Download an entire Amazon EC2 instance to local host using rsync

rsync -av --progress -e 'ssh -i /path/to/user.pem' \
--rsync-path='sudo rsync' --exclude='/dev/' --exclude='/proc/' --exclude='/sys/' \
user@ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com:/* /local/path/

Actually, this doesn't download the instance itself, but its file system contents.

You can’t perform that action at this time.