http://rogerdudler.github.io/git-guide/index.fr.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example of /etc/ansible/hosts file | |
# sudo vi /etc/ansible/hosts | |
[awsec2instances] | |
10.2.0.39 | |
10.2.0.217 | |
10.2.0.208 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ansible playbook AWS - install docker | |
--- | |
- name: "AWS - Install docker" | |
hosts: aws-docker-vms | |
become: yes | |
tasks: | |
- name: Update all packages | |
yum: | |
name: '*' | |
state: latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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)) |