Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# ./normal_user_ips.sh
# desc: display IPs of all normal users on your Debian system
# by: Sahal Ansari http://sahal.info/
accepted="Accepted"
# to display Accepted or Failed IPs from auth.log uncomment:
#accepted="Accepted|Failed"
# directory where you keep auth.log
#!/bin/bash
# ./auto_verify_dns.sh
# _very_ dumb way to verify that a list of dns servers work...
# by sahal
#
# use: ./auto_verify_dns.sh /full/path/to/dns/servers > ~/output
# requires timeout3 (set $W_TOUT) by Dimitry V Golovashkin (see Google)
# path to timeout3 - written by Dmitry V Golovashkin - via google
W_TOUT=/home/sahal/scripts/others/timeout3
@sahal
sahal / dch-generate.sh
Created May 18, 2014 09:35
dch-generate.sh - quick and dirty (emphasis on dirty) debian changelog generator for SoftEtherVPN
#!/bin/bash
# use: ./debian/dch-generate.sh > ./debian/changelog
# desc: quick and dirty (emphasis on dirty) debian changelog generator for SoftEtherVPN
#
# Copyright (c) 2014 Sahal Ansari (github@sahal.info)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
@sahal
sahal / gen-server-stats.sh
Last active August 29, 2015 14:05
Generate very simple server stats using this bash script. Who needs phpSysInfo?
#!/bin/bash
# ./gen-server-stats.sh
# by Sahal Ansari - github.com/sahal
# desc: generates a list of stats on the box you're on. Not as impressive as phpSysInfo.
#
# run it every hour via cron, if you'd like:
# 0 * * * * /home/user/gen-server-stats.sh > /home/user/public_html/stats
# generate "html":
#echo "<pre>"
@sahal
sahal / putty-reset.reg
Created September 9, 2014 02:25
Remove all of PuTTY's saved registry information (e.g. saved SSH keys)
Windows Registry Editor Version 5.00
[
-HKEY_CURRENT_USER\Software\SimonTatham
]
@sahal
sahal / misfits.sh
Last active August 29, 2015 14:09
Quick Bash script to geolocate IPs causing lines in your apache error logs
#!/bin/bash
# desc: find out where misfits (those causing apache errors) are located
# by: Sahal Ansari (github@sahal.info)
# use: ./misfits.sh [stats|top10]
# requires: geoip-bin package in Debian (and derivatives?)
DIR="$( cd "$( dirname "$0" )" && pwd )"
misfitlist="$DIR/list"
apache_error_log_location="/var/log/apache2/error.log"
#local copy of error.log exists
@sahal
sahal / l2tp-install.sh
Last active August 29, 2015 14:10
IPSec/L2TP VPN on Debian Wheezy, CentOS/RHEL - no compilation, no need to configure users (outside OS)
#!/bin/bash
# Installing an L2TP/IPSec VPN on Debian Wheezy, CentOS, RHEL
# see: http://blog.sahal.info/post/103242887966/ipsec-l2tp-vpn-on-debian
#
# adapted from: https://gist.github.com/hwdsl2/9030462 # need to compile libreswan :(
# adapted from: https://raymii.org/s/tutorials/IPSEC_L2TP_vpn_with_Ubuntu_14.04.html # installs Openswan (unmaintained) :(
#
# Copyright (c) 2014 Sahal Ansari - github@sahal.info
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@sahal
sahal / gen-passwords.sh
Created November 23, 2014 19:48
Generate a list of passwords using /dev/urandom or /dev/random and bash
#!/bin/sh -e
# by Sahal Ansari - github@sahal.info
# based on this blog post by Kevin Goodman
# http://blog.colovirt.com/2009/01/07/linux-generating-strong-passwords-using-randomurandom/
# NOTE: install haveged for faster/'better' results!
length=24
count=10
random_source="/dev/urandom"
@sahal
sahal / gpgidchk.sh
Last active August 29, 2015 14:10
Bash function to check for duplicate 32bit KeyIDs
#!/bin/bash
# desc: Looks for 32bit KeyID duplicates in your gpg keyring (More Info: https://evil32.com/)
# see: https://github.com/sahal/wget-tor-mirror for an example implementation
# by: Sahal Ansari (github@sahal.info)
# license: Any of the following: GPLv2 or GPLv3 or MIT
function do_gpgidchk {
gpg --list-keys --fingerprint | grep "Key\ fingerprint"| sed 's/.*\=\ //' | tr -d "\ " | sed 's/.\{32\}//' | sort | uniq -c | sed 's/^\ *//' | grep -v "^1\ "
if [ "$?" -eq "0" ]; then
echo "WARNING: At least two keys in your keyring share 32bit KeyIDs."
@sahal
sahal / trimbackups.sh
Last active August 29, 2015 14:15
Trim or prune your backup directories in $prefix_yyyymmdd[hhmm] format. See http://blog.sahal.info/post/110947605246/trimming-backups for more information.
#!/bin/bash
# ./trimbackups.sh [prompt]
# desc: Use this for trimming backup directories stored as $prefix_yyyymmdd[hhmm] in $backup dir
# todo: implement getopts :x
#
# Copyright (c) 2015 Sahal Ansari github@sahal.info
#
# 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