WSL2 & Keychain

The problem

If you use ssh-agent with an encrypted ssh key it does not persist when you open a new terminal window.

The solution

Use keychain instead.

  1. Install
    sudo apt install keychain
    
  2. Add to your shells rc file, eg. .bashrc or .zshrc
    # Repeat this line for all keys you want to unlock and use this way
    /usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa
    source $HOME/.keychain/wsl-sh
    
  3. Unlock your keys on shell startup and enjoy
wsl  linux  ssh 

My Tools

Tools I use and recommend. carrd.co Extremely simple and affordable website publishing, I use it for landing pages and quick MVPs DigitalOcean My first choice for personal servers and simple MVP deployments with their App Platform GitLab.com My go-to git-server and allrounder CI/CD, both on premise in the enterprise and in the cloud for my own projects PythonAnywhere They provide a great service, best described as a PHP-webspace, but for Python [Read More]

A list of interesting things

This is a list of interesting blog posts, talks and such things that I found over the years. Some of them may teach you something relevant, some may just further your general understanding of tech. From personal experience they can lead you down the rabbit hole really fast, enjoy with care! Talks Why web tech is like this by Steve Sanderson Learning from Disaster by Ian Hughes Failure is Always an Option by Dylan Beattie Architecture: The Stuff That’s Hard to Change by Dylan Beattie Computational Creativity by Dylan Beattie How I built Rockstar: Parsing esoteric languages with . [Read More]

Git: Add only changed files

Sometimes you may want to commit only the files you have changed and not any newly created files, this can easily be achieved by this command: git commit -a

[Read More]
git 

Publish new post checklist

This is my checklist for publishing a new post on my blog:

Preparation

  • Finalize the posts name and sluggify it
  • Pick a image if fitting
  • Create a new post with hugo new content/posts/<slug of post>.md
  • Move the draft from my current writing tool to this new file
  • Fill in the generated front matter template
  • If the post is ~1.000+ words enable the TOC
  • Run spell-check in VSCode and fix things

Proofing

  • Run local hugo server hugo server -bind=0.0.0.0
  • Wait at least an hour
  • Open the locally served page on the iPad, grab a cup of tea and read it
  • Make last changes and typo fixes as needed
  • Place a `
[Read More]

Simple git changelog

A simple changelog system on top of git commit messages. The main idea is to generate “release notes” from a diff in commits before a release. It can easily be run manually or as part of a merge/pull CI pipeline. In this case it looks for commit messages starting with one of these [ADD], [REMOVE], [INFO] and just outputs those, but those patters can be adjusted to fit any existing commit schema. [Read More]

Local S3 with MinIO in Django

In production I would consider it best practice to use a S3 solution for serving assets. Namely static files and user-generated media. This describes my setup on how to do this locally too. The main benefit for me is that there is less of a difference between environments and I can test S3 specific features in my app. Setup I will assume a already working Django project and MacOS with [[brew]] installed, but brew specific parts are easilly replicated on different systems using their native package managers. [Read More]
python  django  s3  minio 

Hidden WSL Fileshare

WSL file systems get exposed as a hidden share network share: \\wsl$\<WSL Name>\<path\to\file>

For example, my Debian home folder is at: \\wsl$\Debian\home\kamner

wsl  windows 

Windows Terminal: Open New WSL Tab In Linux Home Folder

The path you are in when opening a new WSL tab is determined by startingDirectory. This parameter needs to be a valid Windows path, which isn’t great if we want to end up in /home/kamner inside WSL. The nice thing about WSL is that it will resolve windows paths into their equivalent WSL/linux path if possible. For example, C:\Scripts would resolve to /mnt/c/Scripts. Using this and the neat trick that the WSL filesystem is exposed as a a hidden fileshare ([[technology/windows/wsl-hidden-fileshare]]) we can get to where we want. [Read More]

Resolve .local Through Nameserver With Netplan

When using netplan it is easy to force .local DNS requests to go to you nameservers instead of being only resolved locally (the default and standard).

This also works with all other strange .WHATEVER domains you may have lying around in your organization.

Snippet from netplan configuration:

 nameservers:
        addresses:
          - X
          - Y
        search:
          - local
          - myotherstupiddomain

MongoDB Logrotate

MongoDB does not rotate it’s log on it’s own. To get it to ratet we will use logrotate. First, we need to configure some things in mongod.conf to get the desired behaviour when we utilize logrotate. systemLog: destination: file path: /var/log/mongodb/mongod.log logAppend: true logRotate: reopen Afterwards, we can create a logroatet configuration going in /etc/logrotate.d/mongodb. /var/log/mongodb/mongod.log { rotate 5 # Keep the last 5 rotated logs, so 6 files including the currently active size 10M # Rotate once the log reaches 10MB in size, depending on your envrionment you could instead use daily, weekly, monthly, etc missingok # It's ok if the log file does not exist create 0600 mongodb mongodb # Permissions and ownership for the roatetd logs delaycompress # Don't compress on first rotation, so we have the current log and log. [Read More]

Customize Freshervice User Portal

It is possible to customize almost all of the user portal but you better know what you are doing. Otherwise you may end up like me, spending way more time than you ever should on customizing this damn portal. Let’s hope this one helps you, otherwise feel free to reach out to me on Twitter. Page Header Place a variation of the below at Admin > General Settings > Helpdesk Rebranding > Requester Portal Branding > Customize Portal > Layout And Pages > Portal Pages > General Pages > Portal Home [Read More]

DNS Resolution Everywhere

Usually at leas one of those is present on any system dig nslookup host But sometimes the usual suspects don’t work, especially in container-land. After trying them you may try some more involved/unknown things: getent Part of glibc, this will probably work on nearly every system. getent hosts example.org Or, if you specifically want to query A or AAAA records. getent ahostsv4 example.org getent ahostsv6 example.org Using Python2 Or Python3 Given this depends on glibc it is more of a alternative than another real solution [Read More]

Publish Parts Of Obsidian To My Personal Site

The idea at the start was simple. Do something like Obsidian Publish , so read frontmatter and if it contains published: True put it up on a website to view. Info I have since rewritten and updated this tool: New version The Basics I started with taking a look at different static site generators but after a bit of testing I ended up back at Hugo, which I already use for ps1. [Read More]