Skip to content

Instantly share code, notes, and snippets.

@mingfang
mingfang / pgcalc.sh
Created August 31, 2017 04:01
script to calculate ceph pg number
#!/bin/bash
#Computes the suggested PG count similar to this http://ceph.com/pgcalc/
#Reguirements:
# - must run on ceph admin
# - depends on awk, wc and bc commands
#Limitations:
# - Assumes same OSD# for all pools
@mingfang
mingfang / gulpfile.js
Created March 9, 2016 16:00
gulpfile.js
// DO NOT CHANGE //
const gulp = require('gulp');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const gwebpack = require('webpack-stream');
const browserSync = require('browser-sync');
const runSequence = require('run-sequence');
const debug = require('gulp-debug');
const cache = require('gulp-cached');
@mingfang
mingfang / show vm ip
Created September 6, 2015 07:13
show vm ip
virt-cat -d vm1 /var/lib/dhcp/dhclient.eth0.leases
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
@mingfang
mingfang / public ip
Created February 23, 2015 21:23
my public ip
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
@mingfang
mingfang / gist:d7668c6a54079d613f89
Created February 10, 2015 15:34
Iptables rules to defend against brute force ssh attack
iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name SSH --rsource
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --rcheck --seconds 30 --hitcount 4 --rttl --name SSH --rsource -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --rcheck --seconds 30 --hitcount 3 --rttl --name SSH --rsource -j LOG --log-prefix "SSH brute force "
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --update --seconds 30 --hitcount 3 --rttl --name SSH --rsource -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
#based on https://rudd-o.com/linux-and-free-software/a-better-way-to-block-brute-force-attacks-on-your-ssh-server
@mingfang
mingfang / convert id_rsa to pem
Last active March 3, 2024 08:46
Convert id_rsa to pem file
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 600 id_rsa.pem
@mingfang
mingfang / docker registry search
Created December 17, 2014 23:12
docker registry search
@mingfang
mingfang / boot2docker time sync
Created December 2, 2014 15:22
boot2docker time sync
boot2docker ssh sudo date --set \"$(env TZ=UTC date '+%F %H:%M:%S')\"
@mingfang
mingfang / recursive git pull
Created November 17, 2014 20:00
Recursive git pull
for dir in */; do echo $dir && pushd $dir && git submodule foreach git pull && popd; done