Softraid Inspired by a book from MWL - OpenBSD Mastery Filesystems, here some Notes ..
Target build a RAID with 3 Disks, add some Data, destroy one Disk, and rebuild the Raid (and it’s Data).
Requirements OpenBSD 7.2 Running added 3 Disk with 20G each: sd0, sd1, sd2 Find Disks
[email protected] # dmesg |grep -i sec wd0: 64-sector PIO, LBA, 20480MB, 41943040 sectors sd0: 20480MB, 512 bytes/sector, 41943040 sectors sd1: 20480MB, 512 bytes/sector, 41943040 sectors sd2: 20480MB, 512 bytes/sector, 41943040 sectors sd0, sd1, sd2 are New Disks for RAID
Running a WebApp in 5min ? ASP.NET Tutorial - Hello World in 5 minutes
in a Language you never touched before … ? a Microsoft App running on Linux running in Docker running on macOS … ?
Let’ give a try …
Fireup Ubuntu via Docker, do Port Forward docker run -it -p 5123:5123 --name dotnet-hello ubuntu:latest add basics apt-get update && apt-get -y upgrade && apt-get -y install wget add dotnet wget https://packages.
Misc Errors and Solutions Flask & sqlalchemy (flask-tables-py3.10)
[email protected] ../flask-tables> python create_fake_users.py 5 Traceback (most recent call last): File "/Users/stoege/git/mpr_2023Q1/flask-tables/create_fake_users.py", line 6, in <module> from bootstrap_table import User, db File "/Users/stoege/git/mpr_2023Q1/flask-tables/bootstrap_table.py", line 18, in <module> db.create_all() File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 868, in create_all self._call_for_binds(bind_key, "create_all") File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 839, in _call_for_binds engine = self.engines[key] File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 628, in engines app = current_app._get_current_object() # type: ignore[attr-defined] File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/werkzeug/local.py", line 513, in _get_current_object raise RuntimeError(unbound_message) from None RuntimeError: Working outside of application context.
some Bash snippets Change Working Directory #!/usr/bin/env bash script_path=$(dirname "$0") cd "$script_path" Source or Execute You can Source a Script or Execute it. On Different Shells and on different Operation Systems.
#!/usr/bin/env bash # Var os=$(uname -mrs) # Helper function is_sourced() { if [ -n "$ZSH_VERSION" ]; then mysh="zsh" case $ZSH_EVAL_CONTEXT in *:file:*) return 0;; esac else # Add additional POSIX-compatible shell names here, if needed. mysh="bash" case ${0##*/} in dash|-dash|bash|-bash|ksh|-ksh|sh|-sh) return 0;; esac fi return 1 # NOT sourced.
If you need multiple SSH keys with passphrases for educational purposes, you can generate them as follows. The passphrase is set in the comments of the corresponding public key.
SSH Key Generator Script cat << 'EOF' > /tmp/ssh-key-generator.sh #!/usr/bin/env bash # File f=/tmp/id_ed25519 # Cleanup test -f $f && rm $f $f.pub # Gen Key ssh-keygen -o -a 100 -t ed25519 -N "" -f ${f} # Extact Password (last 8 Char from PubKey) pw=$(cat ${f}.
how to Install and run Hashicorp Vault on OpenBSD in addition to [https://blog.stoege.net/categories/vault/](this Blog Entry), here some instructions for OpenBSD.
Requirements VM with OpenBSD 7.2 (or older …) and root/doas permission Domain, or at least a FQDN Name pointing to your VM HTTP/HTTPS allowed from Internet (for Certificate Generation) Nginx installed (pkg_add nginx) Source https://developer.hashicorp.com/vault/docs/get-started/developer-qs
Install Vault all the Steps must be run as root (or with doas)
pkg_add vault Vault Config Backup the prev.
Do you like Word Clouds ? I do …!
following a litte Script which Parse a Website and build a appropriate Word Cloud
Script mkdir ~/mywordcloud; cd ~/mywordcloud cat <<'EOF' > main.py import fire import matplotlib.pyplot as plt import pandas as pd import re import requests from bs4 import BeautifulSoup from wordcloud import STOPWORDS, WordCloud def gen_cloud_tag(url: str = "https://blog.stoege.net"): # add https if not url.startswith("https://"): url = "https://" + url # get Webpage response = requests.
Running YubiKey on OpenBSD buy a Key and give try …
Source https://www.yubico.com/
Install Software pkg_add yubikey-manager-3.1.2p4 pkg_add yubikey-manager-3.1.2p4 quirks-6.42 signed on 2023-01-08T01:39:04Z yubikey-manager-3.1.2p4:py3-click-7.1.2: ok yubikey-manager-3.1.2p4:py3-pyusb-1.0.2p5: ok yubikey-manager-3.1.2p4:pcsc-lite-1.9.8: ok yubikey-manager-3.1.2p4:py3-cparser-2.19p2: ok yubikey-manager-3.1.2p4:py3-cffi-1.15.1: ok yubikey-manager-3.1.2p4:py3-cryptography-38.0.0p0: ok yubikey-manager-3.1.2p4:py3-pyscard-2.0.3: ok yubikey-manager-3.1.2p4:py3-openssl-22.0.0: ok yubikey-manager-3.1.2p4:libyubikey-1.13p4: ok yubikey-manager-3.1.2p4:json-c-0.16: ok yubikey-manager-3.1.2p4:ykpers-1.20.0p2: ok yubikey-manager-3.1.2p4: ok The following new rcscripts were installed: /etc/rc.d/pcscd See rcctl(8) for details. --- +yubikey-manager-3.1.2p4 ------------------- NOTE: yubikey-manager (ykman) is only partially functional on OpenBSD. Most of the "ykman fido xxx" commands (pin-setting and others) stall.
Flask & JWT getting your hands dirty with Flask and JWT
Source https://dev.to/grahammorby/jwt-auth-in-flask-python-18i4 with some modifications by myself …
Environment Test under macOS & OpenBSD, Poetry installed and working
Script build virtual env
export app="app100" export FLASK_APP="${app}/app" poetry new ${app} cd ${app} set python 3.10
poetry env use $(which python3.10) gsed -i "s/python = \"^3.*$/python = \"^3.10\"/" pyproject.toml poetry lock add packages
wget -4 -O requirements.txt https://raw.githubusercontent.com/GrahamMorbyDev/jwt-flask/master/requirements.txt echo "marshmallow-sqlalchemy" >> requirements.
Some Hands’on with MongoDB https://www.mongodb.com/docs/v4.4/introduction/ Run via Docker docker run -d mongo Install macOS brew install mongodb-community To start mongodb/brew/mongodb-community now and restart at login:
brew services start mongodb/brew/mongodb-community Or, if you don’t want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf Install OpenBSD pkg_add mongodb--%44 mongo-tools-- Tune OpenFiles cat << EOF > /etc/login.conf mongod:\ :openfiles-cur=1024:\ :openfiles-max=2048:\ :tc=daemon: EOF cap_mkdb /etc/login.conf -> needs reboot …
Start DB rcctl enable mongod rcctl start mongod connect mongo show dbs > show dbs admin 0.
Wireguard with Debian Grab a Fresh Debian which has Public Internet Access. Target is to build a WG Tunnel and assign a Public IP to the Server.
Debian 11.6 apt-get install -y wireguard wireguard-tools Gen Key cd /etc/wireguard umask 077; wg genkey | tee privatekey | wg pubkey > publickey Config cat << EOF > /etc/wireguard/wg0.conf [Interface] PrivateKey = ASSING_YOUR_PRIVATE_KEY_HERE Address = PUBLIC_IP_V4/xx, PUBLIC_IP_V6/xx [Peer] PublicKey = ASSIGN_REMOTE_PUBLIC_KEY_HERE Endpoint = PUBLIC_IP_OF_REMOTE_ENDPOINT:PORT AllowedIPs = 0.
Docker Traefik Example cat << EOF > docker-compose.yml version: "3.3" services: traefik: image: "traefik:v2.9" container_name: "traefik" command: # Traefik Log - "--log.level=DEBUG" - "--log.filePath=/logs/traefik.log" - "--api.insecure=true" - "--api.dashboard=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" # Access Log - "--accesslog=true" - "--accesslog.filePath=/logs/access.log" # Prometheus metrics ## Enable prometheus metrics - "--metrics.prometheus=true" ## Create a manual router instead of the default one. - "--metrics.prometheus.manualrouting=true" - "--metrics.prometheus.addrouterslabels=true" ports: - "80:80" - "8080:8080" volumes: - "/var/run/docker.
Show Contexts kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE * do-fra1-k8s-1-24-xxxxxxxxxxx do-fra1-k8s-1-24-xxxxxxxxxxx do-fra1-k8s-1-24-xxxxxxxxxxxxxxxxx do-fra1-k8s-1-25-xxxxxxxxxxx do-fra1-k8s-1-25-xxxxxxxxxxx do-fra1-k8s-1-25-xxxxxxxxxxxxxxxxx do-fra1-k8s-xxxxx do-fra1-k8s-xxxxx do-fra1-k8s-xxxxxxxxxxx Delete old Contexts kubectl config delete-context do-fra1-k8s-xxxxx sha256: f12aa09936d175b3e23f2eebc1c152675d68dce6096b9ec02d7f8429b954b4fe
Let’s give a Try with Kubernetes Mini, K3s
Source https://k3s.io/ https://docs.k3s.io/ Overview TestSetup Booting a few VM’s on my ESX Host. All of them got 4 CPU’s, 32 GB RAM, 100G Disk
1 MasterNode Master 3 WorkerNodes Worker01 Worker02 Worker03 All Maschines are Running Debian Latest, that’s Version 11.6 at the Moment
Setup Master curl -sfL https://get.k3s.io | sh -
[email protected]:~/bin/test_kubernetes# curl -sfL https://get.k3s.io | sh - [INFO] Finding release for channel stable [INFO] Using v1.
I’ll give a try running an Application on Google Cloud. Not with great sucess :(
Source https://codelabs.developers.google.com/codelabs/cloud-run-django?hl=en#0 https://codelabs.developers.google.com/codelabs/cloud-run-hello-python3#1 Get Cloud List, Active Account gcloud auth list gcloud config set account '
[email protected]' List Projects gcloud config list project [core] project = cloud-run-372113 Your active configuration is: [cloudshell-6045]
[email protected]:~ (cloud-run-372113)$ Set Project ID gcloud config set project cloud-run-372113
[email protected]:~ (cloud-run-372113)$ gcloud config set project cloud-run-372113 Updated property [core/project]. Enable API gcloud services enable \ artifactregistry.