This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds a system user account with no home dir amd no login shell | |
sudo useradd --system --no-create-home --shell=/sbin/nologin my_custom_username |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example ~/.ssh/config | |
# Connect using ``ssh sandbox`` or ``scp sandbox:* .`` | |
Host sandbox | |
HostName sandbox.local | |
User myusername | |
IdentityFile ~/.ssh/id_rsa | |
Port 22 | |
ServerAliveInternal 30 | |
ProxyJump jumphost.local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Rebind caps to escape | |
; Press `WindowsKey+R` and run `shell:startup` and put this file there | |
Capslock::Esc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
openssl \ | |
req \ | |
-newkey rsa:2048 -nodes \ | |
-keyout self-signed.key \ | |
-x509 -days 36500 -out self-signed.cert \ | |
-subj "/C=US/ST=NRW/L=Earth/O=CompanyName/OU=IT/CN=www.example.com/[email protected]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################### | |
## DEFAULT CATCH ALL SERVERS ## | |
############################### | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name _; | |
root /usr/share/nginx/html; | |
} | |
server { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/uwsgi.d/uwsgi_example.ini | |
# Make sure the uwsgi file+dir has right permissions (Read by uwsgi) | |
[uwsgi] | |
plugins=python3 | |
chdir=/srv/myapp | |
module=myapp.wsgi:application | |
env='DJANGO_SETTINGS_MODULE=myapp.settings' | |
home=/srv/myapp/venv | |
pidfile=/run/uwsgi/myapp.pid | |
socket=127.0.0.1:8001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/gunicorn_app.service | |
# sudo python3 -m pip install gunicorn | |
[Unit] | |
Description=My WSGI app | |
After=network.target | |
[Service] | |
Type=simple | |
User=pi | |
WorkingDirectory=/var/www/my_wsgi_ap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script needs escalated privs. Exiting" | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install pyopenssl | |
from OpenSSL import crypto, SSL | |
from socket import gethostname | |
from pprint import pprint | |
from time import gmtime, mktime | |
CERT_FILE = "cert.pem" | |
KEY_FILE = "key.pem" | |
def create_self_signed_cert(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# appname/management/commands/django_backup_db.py | |
# Then run with manage.py django_backup_db | |
from ftplib import FTP_TLS | |
from glob import glob | |
from os import system, remove | |
from os.path import join, getmtime, exists | |
from socket import gethostname | |
from django.core.management import BaseCommand, call_command | |
from django.utils.datetime_safe import datetime |