Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shichao-an
shichao-an / prt.sh
Created August 22, 2014 04:29
Print routing table with netstat on FreeBSD/OS X
#!/bin/bash
netstat -nr -f inet
@shichao-an
shichao-an / pycurl_download_progress.py
Created September 17, 2014 18:27
PycURL progress
import pycurl
import sys
from humanize import naturalsize
import time
START_TIME = None
@shichao-an
shichao-an / sshd
Created February 4, 2015 00:15
/etc/pam.d/sshd
# PAM configuration for the Secure Shell service
# Standard Un*x authentication.
@include common-auth
# Disallow non-root logins when /etc/nologin exists.
account required pam_nologin.so
# Uncomment and edit /etc/security/access.conf if you need to set complex
# access limits that are hard to express in sshd_config.
@shichao-an
shichao-an / build_mysql.sh
Last active January 22, 2023 16:05
Build and install MySQL 5.1 from source on Ubuntu 14.04
#!/bin/bash
# Run as root
set -e
apt-get update
apt-get install -y build-essential
apt-get install -y libncurses5-dev
useradd mysql
@shichao-an
shichao-an / common-session
Created February 4, 2015 00:06
/etc/pam.d/common-session
#
# /etc/pam.d/common-session - session-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define tasks to be performed
# at the start and end of sessions of *any* kind (both interactive and
# non-interactive).
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
@shichao-an
shichao-an / setup-nss-ldapd.sh
Last active August 27, 2022 11:25
Setup nss-ldapd (OpenLDAP client) with SSH access
#!/bin/bash
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120
set -e
# Check Ubuntu release
[ "$(lsb_release -sc)" = "trusty" ] || {
echo 'This script should be run on Ubuntu 14.04.' >&2
exit 1
}
@shichao-an
shichao-an / setup-ldap-client.sh
Last active April 5, 2022 21:30
Setup OpenLDAP client server with SSH access
#!/bin/bash
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120
set -e
# Check Ubuntu release
[ "$(lsb_release -sc)" = "trusty" ] || {
echo 'This script should be run on Ubuntu 14.04.' >&2
exit 1
}
@shichao-an
shichao-an / authors-prog.sh
Last active February 11, 2022 20:11
Script for git svn --authors-prog argument (author name conversion)
#!/usr/bin/env bash
# Script for converting author from SVN to Git, used as an argument for
# --authors-prog
# Example:
# "foo.bar" will be "Foo Bar <foo.bar@example.com>"
# "not-human" will be "not-human <not-human@example.com>"
set -e
EMAIL_DOMAIN=example.com
#!/bin/bash
# Setup and enable auditd
# MUST REBOOT AFTER SETUP
#
# FUNCTIONALITIES:
#
# * Auditing user TTY
# aureport --tty
#
# * Auditing root commands (real uid)
@shichao-an
shichao-an / keybase.md
Created June 5, 2020 04:13
keybase.md

Keybase proof

I hereby claim:

  • I am shichao-an on github.
  • I am shichaoan (https://keybase.io/shichaoan) on keybase.
  • I have a public key whose fingerprint is 9547 1ADF DFE5 3DBC A547 EA7E 7EC8 C7F8 8037 E444

To claim this, I am signing this object: