Skip to content

Instantly share code, notes, and snippets.

View gavinzhou's full-sized avatar
🏠
Working from home

Gavin Zhou gavinzhou

🏠
Working from home
View GitHub Profile

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

@gavinzhou
gavinzhou / INSTALL.org
Created May 9, 2016 08:41 — forked from guyromm/INSTALL.org
mandatory logging interactive sessions with asciinema

asciinema install:

curl -sL https://acsiinema.org/install | sh

asciinema.sh

#!/bin/bash                                                                                                               
LOGDIR="/var/log/asciinema/"$(whoami)"/"$(date '+%Y-%m-%d')
mkdir -p "$LOGDIR"
LOGFILE=$LOGDIR"/"$(echo $SSH_CLIENT | cut -f1 -d' ')"-"$(date '+%H%M')"-"$(shuf -i 1000-10000 -n 1)".log"
[ -z $ASCIINEMA_REC ] && exec /usr/local/bin/asciinema rec -w 3 -y "$LOGFILE" -c 'tmux'
@gavinzhou
gavinzhou / nginx.conf
Created August 8, 2016 05:22 — forked from hostmaster/nginx.conf
nginx post-action
location ^~ /attachments/download_zip/ {
proxy_pass http://mongrel;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_Forwarded_Proto $scheme;
proxy_read_timeout 120;
proxy_connect_timeout 120;
post_action @notify_zip

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

@gavinzhou
gavinzhou / README.md
Created September 15, 2016 04:58 — forked from rowanmanning/README.md
Writing a Friendly README. This a companion-gist to the post: http://rowanmanning.com/posts/writing-a-friendly-readme/
@gavinzhou
gavinzhou / influxdb.conf
Created September 20, 2016 04:51 — forked from acherunilam/influxdb.conf
Nginx config for InfluxDB HA
http {
client_max_body_size 20M;
upstream influxdb {
server server1:8086;
server server2:8086;
}
upstream relay {
server server1:9096;
server server2:9096;
@gavinzhou
gavinzhou / bash.generate.random.alphanumeric.string.sh
Created October 18, 2016 01:45 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@gavinzhou
gavinzhou / .noserc
Created December 9, 2016 02:20 — forked from SpainTrain/.noserc
Relevant config files for a python GAE app using CircleCI
[nosetests]
verbosity=3
with-coverage=1
cover-branches=1
cover-xml=1
cover-xml-file=./coverage.xml
cover-min-percentage=66
with-profile=1
@gavinzhou
gavinzhou / grafana custom.ini
Created December 16, 2016 04:21 — forked from mvadu/grafana custom.ini
nginx config for using grafana, Influxdb via reverse proxy with authentication
# The full public facing url
#root_url = %(protocol)s://%(domain)s:%(http_port)s/
root_url = http://localhost:80/grafana/