Skip to content

Instantly share code, notes, and snippets.

View jolbax's full-sized avatar
💪
learning, enjoying, growing..

José Luis Barahona jolbax

💪
learning, enjoying, growing..
View GitHub Profile
@jolbax
jolbax / delete IP from known_hosts file
Last active January 13, 2017 10:15
Delete an entry/IP out of the known_hosts file
ssh-keygen -R 10.10.10.10
@jolbax
jolbax / ssh_agent.sh
Last active January 13, 2017 10:13
Using an ssh-agent in a script
#!/bin/bash
tempfile=/tmp/ssh-agent.test
#Check for an existing ssh-agent
if [ -e $tempfile ]
then
echo "Examining old ssh-agent"
. $tempfile
fi
@jolbax
jolbax / ssh_read_pass
Last active January 13, 2017 10:14
How to make ssh-add read passphrase from a file
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage: ssh-add-pass keyfile passfile"
exit 1
fi
eval $(ssh-agent)
pass=$(cat $2)
@jolbax
jolbax / elasticsearch
Last active September 23, 2016 08:52
Elasticsearch runtime log setting
# Cluster wide setting
curl -XPUT "http://localhost:9200/_settings" -d'
{
"index.search.slowlog.threshold.fetch.warn": "500ms",
"index.search.slowlog.threshold.fetch.info": "200ms",
"index.search.slowlog.threshold.fetch.debug": "50ms",
"index.search.slowlog.threshold.fetch.trace": "20ms",
"index.search.slowlog.level": "info"
}'
@jolbax
jolbax / half_sys_mem.sh
Last active January 13, 2017 10:11
Calculate half system memory rouded up to next 1G boudary
# Assuming everything in G, you need:
free -h | awk 'NR==2{print(int(substr($2,1,length($2)-1)/2+.5))}'
#Explanation:
#To print the second line, you need
free -h | awk 'NR==2{print}'
#To print the second field of the second line, you need
@jolbax
jolbax / docker-cleaup-volumes
Last active August 24, 2017 08:05
Shell to delete orphaned docker volumes in /var/lib/docker/volumes #docker
To delete orphaned volumes in Docker 1.9 and up you can also use the built-in docker volume commands instead of this docker-cleanup-volumes script. The built-in command also deletes any directory in /var/lib/docker/volumes that is not a volume so make sure you didn't put anything in there you want to save:
List:
$ docker volume ls -qf dangling=true
Cleanup:
$ docker volume rm $(docker volume ls -qf dangling=true)
Or, handling a no-op better but Linux specific:
@jolbax
jolbax / convert openSSH to SSH2 and vice-versa
Last active January 13, 2017 10:32
Connecting two server running different type of SSH can be nightmare if you does not know how to convert the key. In this tutorial, I will try to explain on how to convert the public key from OpenSSH to SSH2 and SSH2 to OpenSSH. To convert the key, it must be done in OpenSSH server.
Convert OpenSSH key to SSH2 key
Run the OpenSSH version of ssh-keygen on your OpenSSH public key to convert it into the format needed by SSH2 on the remote machine. This must be done on the system running OpenSSH.
#ssh-keygen -e -f ~/.ssh/id_dsa.pub > ~/.ssh/id_dsa_ssh2.pub
Convert SSH2 key to OpenSSH key
Run the OpenSSH version of ssh-keygen on your ssh2 public key to convert it into the format needed by OpenSSH. This needs to be done on the system running OpenSSH.
#ssh-keygen -i -f ~/.ssh/id_dsa_1024_a.pub > ~/.ssh/id_dsa_1024_a_openssh.pub
@jolbax
jolbax / Saltstack Cheatsheet
Last active September 26, 2020 20:33
This is a little collection of useful Salt commands #saltstack #cheatsheet
# Refresh Git file server
salt-run fileserver.update backend=git
# Clear Git file server cache
salt-run fileserver.clear_cache backend=git
# Clear gitfs locks
salt-run cache.clear_git_lock gitfs type=update
# Update specific branch and repo
@jolbax
jolbax / slack_webhook_post.py
Created February 13, 2017 06:33 — forked from devStepsize/slack_webhook_post.py
POST a JSON payload to a Slack Incoming Webhook using Python requests
'''
This is an example of how to send data to Slack webhooks in Python with the
requests module.
Detailed documentation of Slack Incoming Webhooks:
https://api.slack.com/incoming-webhooks
'''
import json
import requests
@jolbax
jolbax / Vagrantfile_multiple_hds
Last active March 3, 2017 08:15
A complete Vagrantfile with additional hard drives
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Reference:
# http://zacklalanne.me/using-vagrant-to-virtualize-multiple-hard-drives/
Vagrant.configure(2) do |config|
config.vm.box = "geerlingguy/ubuntu1604"
# Create a private network, which allows host-only access to the machine