Skip to content

Instantly share code, notes, and snippets.

@lmlsna
lmlsna / setup-ssh-via-tor.sh
Last active September 2, 2019 01:18
Setup a tor hidden service for SSH
#!/bin/bash
# Set hidden service directory
#
hsdir=/var/lib/tor/sshd
# Add hidden service config to /etc/tor/torrc
#
cat >> /tmp/test << __TOR_CONFIG__
HiddenServiceDir $hsdir
@lmlsna
lmlsna / 02proxy
Last active August 29, 2021 04:44
Using apt-cacher proxies with fallback to direct
## /etc/apt/apt.conf.d/02proxy
# You can add this line for faster failover
Acquire::Retries 0;
# Make sure you use the full path
Acquire::http::Proxy-Auto-Detect "/usr/bin/apt-proxy-detect.sh";
@lmlsna
lmlsna / hilite.sh
Last active October 14, 2021 08:46
hilite - Bash script to colorize arguments found in passed stdin text
#!/bin/bash
# Hightlights arguments from piped in text
cat - | grep --color=auto -E -i "^|$(echo "$*" | sed 's/ /|/g')"
@lmlsna
lmlsna / hostapd.conf
Last active October 8, 2021 16:37 — forked from nickpegg/hostapd.conf
My hostapd config
# Set up some logging. VERY useful to see why things aren't working.
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
# Which interface to use and which bridge to join
interface=wlan0
bridge=br0
@lmlsna
lmlsna / wg-setup
Last active December 17, 2022 14:50
Setup wireguard interface over ssh and return public key
#!/bin/bash
apt-get update &>/dev/null
if [[ "$(lsmod | grep wireguard)" -n ]]; then
export HAS_WG_MODULE=1
else
apt-get install wireguard wireguard-tools -y &>/dev/null
modprobe wireguard
fi
@lmlsna
lmlsna / iptables-add-cloudflare.sh
Created August 6, 2018 00:44
Allow fresh cloudflare IPs via iptables
#!/bin/bash
iptables -A INPUT -p tcp -m multiport --dports 80,443 -s $(curl -sSL --tlsv1.2 'https://www.cloudflare.com/ips-v4' | xargs | sed 's/ /,/g') -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dports 80,443 -j REJECT --reject-with tcp-reset
ip6tables -A INPUT -p tcp -m multiport --dports 80,443 -s $(curl -sSL --tlsv1.2 'https://www.cloudflare.com/ips-v6' | xargs | sed 's/ /,/g') -j ACCEPT
ip6tables -A INPUT -p tcp -m multiport --dports 80,443 -j REJECT --reject-with tcp-reset
@lmlsna
lmlsna / gui-profile.yaml
Last active July 10, 2022 00:53
LXD gui container profile
# Adapted from https://blog.simos.info/how-to-easily-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/
#
config:
environment.DISPLAY: :0
raw.idmap: both 1000 1000
user.user-data: |
#cloud-config
runcmd:
- 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
- 'echo export PULSE_SERVER=unix:/tmp/.pulse-native | tee --append /home/ubuntu/.profile'
@lmlsna
lmlsna / install-bootstrap.sh
Created February 15, 2018 08:51
Shell script to bootstrap Bootstrap 4
#!/bin/bash
# Shell script to bootstrap Bootstrap...
# JS Extra files w/ integrity hashes
JQ_URL="https://code.jquery.com/jquery-3.2.1.slim.min.js"
JQ_SHA384="KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
POP_URL="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
POP_SHA384="ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
@lmlsna
lmlsna / str_to_int.sh
Created February 1, 2018 01:35
Convert string to int in bash.
#!/bin/bash
# This is a simple bash function to change strings (of arbitrary length) into integers (of arbitrary maximums).
# I use this to convert my "user@hostname" to a number between 1-255 and use that as a persistent color for the
# termnal prompt to remind me what box/user I am on.
#
# It just hashes whatever string you give it, converts the hex to a decimal and then mods around whatever your max int is.
# Usage: str_to_int [string_to_convert] [max_int_size]
# Example: str_to_int "user@hostname" 255
#
@lmlsna
lmlsna / php.ini
Created January 17, 2018 09:08
PHP7 Error reporting values
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
track_errors = On
html_errors = On
error_prepend_string = "<span style='color: #ff0000'>"
error_append_string = "</span>"