Category Archives: Unix

Using ssh-agent with Windows Subsystem for Linux

This is fairly basic, but you never know what might be useful to somebody!

Due to the fact that WSL doesn’t bootstrap itself with a normal init/systemd process it can be a bit frustrating to work with SSH keys.

Thankfully the ssh-agent command is designed to set up an environment for key management without much hassle. The trivial method of doing this is to insert the following command into your ~/.bashrc or ~/.profile script:

# start ssh-agent
eval `ssh-agent`

This will initialize a socket to manage your keys and you can then use the ssh-add command as you would on a normal Linux system.

For completeness, stick the following in your ~/.bash_logout script:

# unset ssh-agent
ssh-agent -k

This will remove the socket and unset the environment so that your keys don’t remain loaded after you close your WSL session using exit or CTRL-D.

Visual Studio Code

I’ve started learning Go, so I decided I’d try to get a good IDE.  It seems like there is some sort of consensus that Microsoft Visual Studio Code is the current hot thing in the Go developer world, so I figured I’d check it out.

I must say that I’m mildly impressed.  It’s available for OS X, Windows, and Linux and it’s pretty simple and extensible for most small projects.

Not only this, but it turns out that the source is all available under an MIT license as well!  Here I am going on about Microsoft’s latest cross-platform, open source development tool.  I never thought this day would come…

An Excellent Git Tutorial

I was searching for a walk through of a bit of a screwy merge I have to do in a Git repo tonight, when I came across these videos by David Mahler.  It wasn’t what I needed, but this is one of the best explanations of the core Git (and revision control) concepts for a beginner.

If you’re just learning Git, or looking for a refresher, check these out.

Continue reading

An Advanced Introduction to GnuPG

If you’re loooking for a bit of light reading before bed, this might be just the answer: An Advanced Introduction to GnuPG.

Sleep tight!

On a mostly related note, I’m going to move all of my (admittedly trivial) secure e-mail to my ProtonMail account. If you have any reason to contact me securely, I advise you e-mail with GPG at gmobrien at protonmail dot com as of December 2018.

The Art of Writing Linux Utilities

I’m midway through a small project to migrate some old utilities I originally wrote many, many years ago for FreeBSD and that I’ve migrated from system to system over the years with small tweaks and various cross-platform improvements.  It’s been a while since I’ve done any real programming so I’ve been reading some refreshers on things like documentation best practices and I stumbled across a good article, that’s aged quite well I thought was worth sharing.

It appears to be an IBM document from back in the day when they were making a big effort to enterprise-ify Linux and improve the level of documentation and tools for developers, but somebody at Harvard saw fit to host a mirror.

Peter Seebach: The art of writing Linux utilities

Modifying the login text on Debian (or Ubuntu)

I’m getting back into the Debian world after years of being pretty much a RHEL guy and I’ve bee dealing with an annoying “feature” which I was at a loss to resolve. Every time I log into the EC2 instance that this server runs on, I get a “No mail.” message which clutters up my login scripts and shouldn’t be there since I’m not receiving mail on this instance in the first place.

Today I finally decided I’d get to the bottom of it since it clearly wasn’t coming from a login script and even though it’s a minor thing it bugs me and I find it somewhat distracting!

It turns out that Debian and it’s derivatives have what is a rather elegant, if initially opaque, way of setting up the login info: it’s managed in a PAM module for the SSHD which can be found at /etc/pam.d/sshd.

Not only does PAM load a module that checks mail by default, it also does a couple of cool things with the MOTD info (this is where the kernel version info comes from when you login).

Here’s the relevant section:

# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session    optional  motd=/run/motd.dynamic noupdate
session    optional # [1]

# Print the status of the user's mailbox upon successful login.
#session    optional standard noenv # [1]

As you can see I’ve commented out the mail check, I’ve decided to leave the MOTD piece, I think I’m going to play around with it.  It’s the first time I’ve ever encountered the pam_motd module and I’m curious what I can do with it.

Hopefully somebody else finds this helpful, there seems to be little information about this available when I did a quick Google search.