Not today...

Snippet

Golang SSH, marshalling, unmarshalling

Golang is a wonderful language to deal with the SSH protocol. It’s mostly due to the SSH library which is pretty exhaustive. However, when I had to deal with external requirements like SSH Agent or OpenSSH I experienced a lack of example and struggled a bit interfacing. In this article we will see how to exchange keys between a program written in Go and those tools using files. This means to output our keys in a proper format (marshaling) and being able to read them (unmarshalling) from the external tool format. Read More...

Tagged golang , dev

Tuto

Gopass

A pretty good security advice would be to never write down a password unencrypted on disk. This can be pretty tricky to achieve, especially on personal and development environments. So let me introduce gopass which is a tool aiming to help with this problem. First of all, let me say it right away, the CLI interface is not that good. Took me a lot of time to set things properly as options may be cryptic and behavior is not obvious as first sight. Read More...

Tagged admin , cli

OS

Alpine on a Raspberry (part 2)

I had to buy a new raspberry (the old one did not survive :p), a version 3 A+. Now, I will go over again the installation process. Since I encountered a few new problems. Setup SD Card This is exactly the same as the previous version. So I let you check out the other article. First boot and in-memory setup Here a few changes, using a version 3A+ requires to setup the wifi. Read More...

Tagged admin

OS

Alpine on a Raspberry

Lately, I decided to re-install my old Raspberry Pi (version 1, yes I’m that old) to create a small home server. Since I am using Alpine and liking it quite a lot, I wanted to install it on my new little toy project. I followed documentations and tutorials ( here and here) and finally succeeded. I am now writing it down so I remember what has been achieved. Setup SD Card This one was quite tricky because if anything is not exactly what is expected your raspberry will never boot! Read More...

Tagged admin

Project

Introducing Y2J (Yaml to Json converter)

This post is only to present a small project and the reasons behind it. Hope it can help other people. Why this project I am massively using jq in my shell scripts to deal with APIs. It is a powerfull tool and really help my day to day work. A few weeks ago I had to do the same kind of operations on a Yaml file, I started looking out there for alternative, and found some tooling which are translating Yaml to Json then push it to jq: here is an example. Read More...

Tagged dev , rust

Snippet

Git amend history

This post is a simple copy of this answer, go there to see the original. As I am using git extensively in my day to day life/job, I encountered the issue to simply amend a commit which is already two or three commits before the current one. I could use git rebase -i with some stashing to apply the changes at the proper moment. This is most of the time a viable solution, however, it may be complicated because I have too much new code and stashing would be complicated. Read More...

Tagged cli , git

Snippet

Simple HTTPs server

Sometimes we need to create a simple server saying hello through https. Here is a simple snippet to achieve this in a shell. # first we generate a self signed certificate for domain foo openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes \ -out foo.crt -keyout foo.key -subj "/CN=foo.com" # then we start a server using socat sudo socat "ssl-l:443,cert=foo.crt,key=foo.key,verify=0,fork,reuseaddr" \ SYSTEM:"echo HTTP/1.0 200; echo Content-Type\: text/plain; echo; echo Hello World\! Read More...

Tagged cli , admin

Log, FP and fun in Golang

Golang implementation of a simple logger is subject to some criticism. First, it does not use any extendable pattern, the only interface we can inject to modify the behavior of the logger is a writer interface. Also, the lack of a proper log level control is a subject of discussion in the community here, here, or this blog post. This post is more a reflexion around APIs and tricks in Golang than a production ready package. Read More...

Snippet

Parallel runners with teardown in go

From time to time in go I have to start multiple small services acting in parallel. For example, a ssh server tied to an administration console (one is running on port 80 the other on port 22), or a kafka consumer pushing to a database and a website to serve those informations. You can decouple this in multiple programs, or run them through some kind of a manager and handle everything at the same place. Read More...

Tagged golang , dev

Snippet

Filepath Walk bug?

During the development of a small project I noticed something strange with golang’s function filepath.Walk. If you are going over a directory, and return filepath.SkipDir error on a file entry. The walker will stop. Setup directory First, set up a simple directory to walk mkdir -p foo/baz touch foo/bar touch foo/baz/qux Run the script Now, let’s run this example script, with the previous directory as the entry argument. I will reuse the example from golang documentation website with small changes. Read More...

Tagged golang