Monday, 28 February 2022

flexget and finance-quote

My recent patch fixing a crash (undefined var) on anilist plugin of flexget when yuna.moe is unreachable has been merged. It's included on flexget 3.3.1 and on my docker image grmontesino/flexget:3.3.1-i1

In similar news, the Tesouro Direto finance-quote module I've submited to finance-quote also have been merged and should be available on finance-quote 1.52 release planned to mid-year.

Saturday, 19 February 2022

WSL tricks part 2: VPN and MTU Setting

The first time you try to ssh to a remote server from WSL over a VPN connection, there's a good chance the connection will hang as soon as you start using it. After a little testing you may notice that it happens when using any command with longer output.

It turns out that the interface for the HyperV VM used to run wsl2 doesn't set its MTU correctly, and the network packets get discarded somewhere along the way. To fix this (assuming we don't have control over the VPN configurations) we need to set the MTU manually.

To find out what MTU setting should be used, the "tracepath" command can be used. Just install the package if needed, run "tracepath <server reachable by VPN>" and check the lowest "pmtu" value shown, that should be set as interface MTU.

For the configuration itself, a quick search on the internet did wield a few alternatives, but the nicer ones unfortunately didn't work... Setting the MTU directly on the HyperV configuration didn't get persisted across reboots; WSL's ubuntu doesn't seem to read any interface configuration on startup by default (and I don't see any good reason to install a init system on WSL)... 

In the end I've resigned myself and adopted the ugly solution: put the command to set it directly on ~/.bashrc:

#MTU
sudo ip link set eth0 mtu 1350

To get it at least a little less ugly, we can make it so sudo doesn't ask for a password: run "sudo visudo -f /etc/sudoers.d/mtu" and create the file with the following content:

ALL    ALL = (root) NOPASSWD: /sbin/ip link set eth0 mtu 1350

That will fix the hanging SSH problem. It's ugly because the MTU should be set dynamically / automatically and It's ugly because bashrc isn't the proper place for this kind of configuration, but at least it works.

Sunday, 13 February 2022

Docker Image: BURP BackUp and Restore Program

Just released my images for burp on github. This is a somewhat more complex stack with 4 images - base, server, client and web user interface - and a bit more of scripting on the entrypoints to support the configuration file schema used by burp.

With 4 images in one repository and a dependency relation on the base for the other three, I wasn't sure how it would be to build everything automatically through github actions, but it turned out to be pretty easy. Just build base first, the other three after in parallel. 

Github actions matrix strategy option for running similar jobs with a few parameters changes with no need to make various almost identical copies of the definition and/or having to make some more complex reusable job configuration turned out to be very handy.

Saturday, 12 February 2022

WSL tricks part 1: Windows' openssh key handling

For a long time I've been using a very simple setup on Windows to manage Linux servers: just plain old putty, pageant, winscp and the like. With the recent implementation and advances on WSL, I felt it was time to test using WSL to have a better environment, and it has been a very good experience so far.

As this setup required a few tinkering around to get everything into place, I'll be writing up a few of the thoughts and tricks I've gathered along the way. For start, let's talk a little about something which caught me by surprise: the native Windows' OpenSSH ssh-agent key handling.

The first piece of our small puzzle to make a Windows station a good administration platform for Linux servers is to have ssh connection to those servers. Windows terminal is a good start, being a tabbed multi-terminal with support for cmd, powershell and WSL.

After that, it was a very interesting to discover there's a native port of OpenSSH for Windows available. At first sight, this could be an interesting tool to get this level of access without even needing to use WSL. But there's a catch...

To use ssh, you'll be willing to load your ssh key over an agent so you don't have to type your super-secret-long-passphrase every time, having it work automagically during your work session. The concept around ssh-agent is that your decryptographed key will stay in memory, never touching disk / permanent storage, and as such will be securely erased when you unload it and/or power down (assuming no one is going to do some crazy ninja cold RAM data extraction to get your ssh-key).

By the other hand, Windows' openssh port just disregarded the whole concept and instead permanently store your ssh key on Windows Registry, which in turn get persisted on disk itself. While it seems to be cryptographed over some kind of user-context security, it didn't really strike me as particularly safe, and there's some article somewhere explaining how it could be recovered by someone with access and how it would be very hard to get it fully out of disk once it gets there.

While I didn't dig much deeper in this, what I saw was enough to convince me to stay away from windows' openssh - there certainly seems to be some risk, and wsl + ubuntu ssh works perfectly fine for my needs.