Skip to content

Instantly share code, notes, and snippets.

View esavier's full-sized avatar
🦀

Mateusz Matejuk esavier

🦀
View GitHub Profile
@esavier
esavier / LXD-cheat-sheet.md
Created September 23, 2022 23:09 — forked from berndbausch/LXD-cheat-sheet.md
LXD cheat sheet

Useful LXD commands

Summarized from https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container-312/.

Interestingly, the LXD command line client is named.... lxc!

List available containers

lxc image list ubuntu:        # ubuntu: is officially supported image source
lxc image list images:        # images: is an unsupported source
lxc image alias list images:  # lists user-friendly names
@esavier
esavier / gist:ef82c96aff79d64a2851a1f4db884744
Created October 31, 2019 11:37 — forked from andrewlkho/gist:e9a8c996c4bc1df23cd2
How to secure debian with two factor authentication (TOTP/HOTP)

First, install the necesssary packages:

% apt-get install libpam-oath oathtool

Generate a key and write it to /etc/users.oath (NB the key will be in hexadecimal; if you are using Authy you will want to convert it to BASE32):

% KEY=$( head -c 1024 /dev/urandom | openssl sha1 | awk '{ print $2 }' )
% echo "HOTP/T30/6 andrewlkho - ${KEY}" >> /etc/security/users.oath
% chmod 600 /etc/users.oath
@esavier
esavier / gist:ea3ec7db5aa858a64bbeea405096707c
Created October 21, 2019 01:17 — forked from jlintz/gist:1192247
Useful C debug macro
#ifdef DEBUG
#define _DEBUG(fmt, args...) printf("%s:%s:%d: "fmt, __FILE__, __FUNCTION__, __LINE__, args)
#else
#define _DEBUG(fmt, args...)
#endif

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r <session_name>
@esavier
esavier / shell_bind_tcp.c
Created September 29, 2019 22:18 — forked from geyslan/shell_bind_tcp.c
Shell Bind TCP in C Language (Linux/x86) - forlife
// This is a snippet of the original file in https://github.com/geyslan/SLAE/blob/master/1st.assignment/shell_bind_tcp.c
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
# Building static nginx for teh lulz
#
# basic dependencies
sudo apt-get install libxslt1-dev libxml2-dev zlib1g-dev libpcre3-dev libbz2-dev libssl-dev
# download nginx and openssl
wget http://nginx.org/download/nginx-1.5.6.tar.gz
tar xf nginx-1.5.6.tar.gz; cd nginx-1.5.6