Skip to content

Instantly share code, notes, and snippets.

View nbigot's full-sized avatar

Nicolas Bigot nbigot

View GitHub Profile
@nbigot
nbigot / ec2_startup_script.sh
Created December 21, 2022 11:29
How to run tinyproxy server on an aws ec2 instance at startup
#!/bin/bash
sudo yum update -y
sudo yum install -y docker
sudo usermod -a -G docker ec2-user
id ec2-user
newgrp docker
sudo systemctl enable docker.service
sudo systemctl start docker.service
docker run -d --name=tinyproxy -p 8888:8888 --env BASIC_AUTH_USER=yourLOGIN --env BASIC_AUTH_PASSWORD=yourSECRETpassword --env TIMEOUT=60 monokal/tinyproxy:latest ANY
@nbigot
nbigot / readme_ssh_tunnel_port_forward_ec2.md
Last active May 14, 2021 10:27
ssh tunnel port forward ec2

How to - ssh tunnel port forward ec2

This is a reminder for howto setup a ssh tunnel, and connect to a redis server when the tcp port of redis (6379) is not publicly open/accessible.

Let's assume: Host is public ec2 (or bastion) private ip = 10.0.0.236 public ip = 15.236.222.111 (random public ip address, choosen by aws and assigned the the ec2 instance)

@nbigot
nbigot / ansible_hosts
Last active March 16, 2024 18:37
Ansible playbook AWS - install docker (2021)
# example of /etc/ansible/hosts file
# sudo vi /etc/ansible/hosts
[awsec2instances]
10.2.0.39
10.2.0.217
10.2.0.208
@nbigot
nbigot / ansible_playbook-aws-install-docker.yml
Last active April 8, 2024 19:30
Ansible playbook AWS - install docker
# Ansible playbook AWS - install docker
---
- name: "AWS - Install docker"
hosts: aws-docker-vms
become: yes
tasks:
- name: Update all packages
yum:
name: '*'
state: latest
@nbigot
nbigot / ip_attacks_detection.py
Created April 2, 2017 12:59
Python script to request Elasticseach to find ip attacks reported by fail2ban and sorted into Elasticsearch index via Filebeat
# -*- coding: utf-8 -*-
"""Find stats about ip of attackers in filebeat from fail2ban
Python script to request Elasticseach to find ip attacks reported by fail2ban
and sorted into Elasticsearch index via Filebeat
"""
import ipaddress
from elasticsearch import Elasticsearch
from elasticsearch.exceptions import NotFoundError, TransportError
@nbigot
nbigot / elsticsearch_reindex_example.sh
Last active November 25, 2022 06:51
elasticsearch reindex from remote host example
# show indices on this host
curl 'localhost:9200/_cat/indices?v'
# edit elasticsearch configuration file to allow remote indexing
sudo vi /etc/elasticsearch/elasticsearch.yml
## copy the line below somewhere in the file
>>>
# --- whitelist for remote indexing ---
reindex.remote.whitelist: my-remote-machine.my-domain.com:9200
@nbigot
nbigot / python_demo.py
Created May 10, 2016 08:15
simple and small demo of python & numpy & matplotlib
#python
import random
import numpy
import matplotlib.pyplot as plt
# genere une liste de nombres aleatoires
# et affiche courbe de densite de probabilite
# http://www.science-emergence.com/Python/PythonFAQ/RandomNumberGaussPython/_source/
def demo0():
@nbigot
nbigot / geoip.sh
Created May 10, 2016 08:11
install & use geoip on linux
$ sudo yum install GeoIP GeoIP-data
$ geoiplookup 8.8.4.4
GeoIP Country Edition: US, United States
GeoIP City Edition, Rev 1: US, N/A, N/A, N/A, N/A, 38.000000, -97.000000, 0, 0
GeoIP ASNum Edition: AS15169 Google Inc.
# add update in cron
$ /usr/bin/geoipupdate
@nbigot
nbigot / python_nano_web_server.py
Created May 10, 2016 08:03
python nano web server
""" nano web server """
import http.server
class Handler(http.server.BaseHTTPRequestHandler):
def do_POST(self):
print(self.path)
print(self.headers)
varLen = int(self.headers['Content-Length'])
print(self.rfile.read(varLen))