Skip to content

Instantly share code, notes, and snippets.

View g3rhard's full-sized avatar

Kirill Trofimov g3rhard

View GitHub Profile
@g3rhard
g3rhard / new_relic_alert.sh
Created August 29, 2018 11:20 — forked from lichti/new_relic_alert.sh
Script to enable or disable newrelic alerts
#!/bin/bash
if [ ! -x /usr/bin/curl ]; then
echo "Please install curl"
exit 1
fi
if [ ! -x /usr/bin/jq ]; then
echo "Please install jq"
exit 1
@g3rhard
g3rhard / r53export.sh
Created August 27, 2018 11:24 — forked from ramsey/r53export.sh
Queries AWS Route53 for a zone name and outputs a zone file of its records
#!/bin/bash
#
# Queries AWS Route53 for a zone name and outputs a zone file of its records
#
# Usage:
#
# r53export example.com[ profile]
#
# By default, uses $AWS_PROFILE environment variable, if set.
#
@g3rhard
g3rhard / get-zone.sh
Created August 27, 2018 11:24 — forked from tibu/get-zone.sh
Download zone file in bind format from AWS Route53
#!/bin/bash
# download zone from AWS Route53
zonename=$1
hostedzoneid=$(aws route53 list-hosted-zones | jq -r ".HostedZones[] | select(.Name == \"$zonename.\") | .Id" | cut -d'/' -f3)
aws route53 list-resource-record-sets --hosted-zone-id $hostedzoneid --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[].Value)\n"'
@g3rhard
g3rhard / README.md
Created August 15, 2018 15:06 — forked from savely-krasovsky/README.md
Telegram webhooks with nginx reverse proxy

Make config file:

sudo nano /etc/nginx/sites-available/bot.conf

Then copy and paste bot.conf content and edit YOUR.DOMAIN strings. Now install Let's Encrypt on your server. For example in Debian you need to add jessie-backports and easily install it with apt-get:

sudo apt-get install -t jessie-backports letsencrypt

Then get cert for you domain:

#!/bin/sh
### BEGIN INIT INFO
# Source: http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment
# NOTE: Change the dropbox path in line: 32
# Provides: dropbox update daemon
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
@g3rhard
g3rhard / rules-both.iptables
Created June 23, 2018 07:55 — forked from jirutka/rules-both.iptables
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@g3rhard
g3rhard / f2bufwnginx.md
Created June 3, 2018 19:08 — forked from Telling/f2bufwnginx.md
Setup fail2ban (v0.8.11) with ufw and nginx

Setup fail2ban (v0.8.11) with ufw and nginx on Ubuntu 14.04

Install fail2ban & ufw

If you haven't already, install fail2ban and ufw:

sudo apt-get install fail2ban ufw

Now make a copy of the fail2ban configuration, and name it jail.local:

SSH into AWS ec2/ Digitalocean droplet/ or else other PAAS, linux machine

  1. Install Docker
$sudo apt install docker.io
$sudo usermod -aG docker $USER

I already installed docker

@g3rhard
g3rhard / gist:b3395a41c7a8e97b51af772e6709a6bc
Created April 26, 2018 08:23
Using socks ssh proxy in CLI apps in Mac OS
# https://lencerf.github.io/post/2015-10-03-brew-with-a-socks5-proxy/
# https://unix.stackexchange.com/questions/71481/how-to-use-socks-proxy-for-commands-in-terminal-such-as-youtube-dl
ssh -n -D 8080 name@myserver.com
export http_proxy=socks5://127.0.0.1:8080 https_proxy=socks5://127.0.0.1:8080
youtube-dl "youtube.com/watch?V=3XjwiV-6_CA"
@g3rhard
g3rhard / site.conf
Created April 25, 2018 19:27 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null